From d61140731d698d62258a7c8bb6b649cb7a4a7ea6 Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Sun, 27 Dec 2015 18:46:17 +0200
Subject: [PATCH 2/2] Fix test script regexp syntax for Perl 5.22

Perl 5.22 introduced the warning

 Unescaped left brace in regex is deprecated, passed through in regex

which triggers in these regexps.

Bug: https://rt.cpan.org/Public/Bug/Display.html?id=110663
---
 t/01_basic.t     |   4 +-
 t/02_xss.t       | Bin 45684 -> 45691 bytes
 t/03_styles.t    | 136 ++++++++---------
 t/04_imports.t   |   2 +-
 t/05_callbacks.t | 442 +++++++++++++++++++++++++++----------------------------
 t/06_unicode.t   |   2 +-
 6 files changed, 293 insertions(+), 293 deletions(-)

diff --git a/t/01_basic.t b/t/01_basic.t
index 91a91f0..b1efcc3 100755
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -456,8 +456,8 @@ $H = <<EOF;
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{<!--$CommentStartText\[if gte mso 10\]> <mce:style><!    /\* Style Definitions \*/  table.MsoNormalTable	{mso-fareast-font-family:"Times New Roman";}  $CommentEndText--> <!--$CommentStartText\[endif\]$CommentEndText--></p>
-<p>&nbsp;<span style="font-size: medium;">I need your help now!</span></p>}, "IE conditional comment without appropriate closing tag");
+like($Res, qr[<!--$CommentStartText\[if gte mso 10\]> <mce:style><!    /\* Style Definitions \*/  table.MsoNormalTable	\{mso-fareast-font-family:"Times New Roman";}  $CommentEndText--> <!--$CommentStartText\[endif\]$CommentEndText--></p>
+<p>&nbsp;<span style="font-size: medium;">I need your help now!</span></p>], "IE conditional comment without appropriate closing tag");
 
 $H = <<'EOF';
 1:<br>
diff --git a/t/02_xss.t b/t/02_xss.t
index 794340c..b4adbff 100644
Binary files a/t/02_xss.t and b/t/02_xss.t differ
diff --git a/t/03_styles.t b/t/03_styles.t
index 5bf83d5..352286e 100644
--- a/t/03_styles.t
+++ b/t/03_styles.t
@@ -40,9 +40,9 @@ p {font-family: "sans serif"}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-p {font-family: "sans serif"}
-$CommentEndText--></style>$}s, "Style tag property with quotes and space");
+like($Res, qr[^<style><!--${CommentStartText}
+p \{font-family: "sans serif"}
+$CommentEndText--></style>$]s, "Style tag property with quotes and space");
 
 $H = <<EOF;
 <style>
@@ -51,10 +51,10 @@ p {text-align:center;color:red}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-p {text-align:center;color:red}
+like($Res, qr[^<style><!--${CommentStartText}
+p \{text-align:center;color:red}
 $CommentEndText--></style>
-$}s, "Multiple properties");
+$]s, "Multiple properties");
 
 $H = <<EOF;
 <style>
@@ -68,15 +68,15 @@ font-family: arial
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
+like($Res, qr[^<style><!--${CommentStartText}
 p
-{
+\{
 text-align: center;
 color: black;
 font-family: arial
 }
 $CommentEndText--></style>
-$}s, "Multiple properties in readable format");
+$]s, "Multiple properties in readable format");
 
 $H = <<EOF;
 <style>
@@ -88,13 +88,13 @@ color: green
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
+like($Res, qr[^<style><!--${CommentStartText}
 h1,h2,h3,h4,h5,h6 
-{
+\{
 color: green
 }
 $CommentEndText--></style>
-$}s, "Multiple selectors");
+$]s, "Multiple selectors");
 
 $H = <<EOF;
 <style>
@@ -104,11 +104,11 @@ p.center {text-align: center}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-p.right {text-align: right}
-p.center {text-align: center}
+like($Res, qr[^<style><!--${CommentStartText}
+p.right \{text-align: right}
+p.center \{text-align: center}
 $CommentEndText--></style>
-$}s, "Selector with a period");
+$]s, "Selector with a period");
 
 $H = <<EOF;
 <style>
@@ -117,10 +117,10 @@ $H = <<EOF;
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-.center {text-align: center}
+like($Res, qr[^<style><!--${CommentStartText}
+.center \{text-align: center}
 $CommentEndText--></style>
-$}, "Selector starting in a period");
+$], "Selector starting in a period");
 
 $H = <<EOF;
 <style>
@@ -129,10 +129,10 @@ input[type="text"] {background-color: blue}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-input\[type="text"\] {background-color: blue}
+like($Res, qr[^<style><!--${CommentStartText}
+input\[type="text"\] \{background-color: blue}
 $CommentEndText--></style>
-$}s, "Selector with square brackets");
+$]s, "Selector with square brackets");
 
 $H = <<EOF;
 <style>
@@ -141,10 +141,10 @@ $H = <<EOF;
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-#green {color: green}
+like($Res, qr[^<style><!--${CommentStartText}
+#green \{color: green}
 $CommentEndText--></style>
-$}s, "Selector starting with a hash");
+$]s, "Selector starting with a hash");
 
 $H = <<EOF;
 <style>
@@ -157,14 +157,14 @@ color: red
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
+like($Res, qr[^<style><!--${CommentStartText}
 p#para1
-{
+\{
 text-align: center;
 color: red
 }
 $CommentEndText--></style>
-$}s, "Selector with a hash");
+$]s, "Selector with a hash");
 
 $H = <<EOF;
 <style>
@@ -183,17 +183,17 @@ comment here
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
+like($Res, qr[^<style><!--${CommentStartText}
 
 p
-{
+\{
 text-align: center;
 
 color: black;
 font-family: arial 
 }
 $CommentEndText--></style>
-$}s, "All sorts of comments");
+$]s, "All sorts of comments");
 
 $H = <<EOF;
 <style>
@@ -249,14 +249,14 @@ $H = <<EOF;
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<STYLE><!--${CommentStartText}BODY{/\*-moz-binding:url\("http://ha.ckers.org/xssmoz.xml#xss"\)\*/}$CommentEndText--></STYLE>$}s, "Remote style sheet part 4");
+like($Res, qr[^<STYLE><!--${CommentStartText}BODY\{/\*-moz-binding:url\("http://ha.ckers.org/xssmoz.xml#xss"\)\*/}$CommentEndText--></STYLE>$]s, "Remote style sheet part 4");
 
 $H = <<EOF;
 <STYLE>li {list-style-image: url("javascript:alert('XSS')");}</STYLE><UL><LI>XSS
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<STYLE><!--${CommentStartText}li {/\*list-style-image: url\("javascript:alert\('XSS'\)"\);\*/}$CommentEndText--></STYLE><UL><LI>XSS$}s, "List-style-image");
+like($Res, qr[^<STYLE><!--${CommentStartText}li \{/\*list-style-image: url\("javascript:alert\('XSS'\)"\);\*/}$CommentEndText--></STYLE><UL><LI>XSS$]s, "List-style-image");
 
 $H = <<'EOF';
 <STYLE>@im\port'\ja\vasc\ript:alert("XSS")';</STYLE>
@@ -276,9 +276,9 @@ $H = <<EOF;
 a{sss:sss}</STYLE>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^<STYLE><!--${CommentStartText}
+like($Res, qr[^<STYLE><!--${CommentStartText}
 
-a{sss:sss}$CommentEndText--></STYLE>$}s, "Removing multiple css imports");
+a\{sss:sss}$CommentEndText--></STYLE>$]s, "Removing multiple css imports");
 
 $H = <<EOF;
 <STYLE>\@import'javascript:alert("XSS")';
@@ -291,14 +291,14 @@ a{sss:11111111}</STYLE>
 a{sss:22222222}</STYLE>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^<STYLE><!--${CommentStartText}
+like($Res, qr[^<STYLE><!--${CommentStartText}
 
-a{sss:11111111}$CommentEndText--></STYLE>
+a\{sss:11111111}$CommentEndText--></STYLE>
 <!--defang_someunknowntag-->
 <br>
 <STYLE><!--${CommentStartText}
 
-a{sss:22222222}$CommentEndText--></STYLE>$}s, "Removing multiple css imports with multiple styles");
+a\{sss:22222222}$CommentEndText--></STYLE>$]s, "Removing multiple css imports with multiple styles");
 
 $H = <<EOF;
 <STYLE>
@@ -308,11 +308,11 @@ p {property: value}
 </STYLE>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^<STYLE>
+like($Res, qr[^<STYLE>
 <!--${CommentStartText}
-p {property: value}
+p \{property: value}
 $CommentEndText-->
-</STYLE>$}s, "Removing HTML comments");
+</STYLE>$]s, "Removing HTML comments");
 
 
 # Tests taken from http://imfo.ru/csstest/css_hacks/import.php
@@ -471,7 +471,7 @@ $H = <<EOF;
 <style>em{color:red};\@import url(&#34;style.css&#34;);</style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^<style><!--${CommentStartText}em{color:red}$CommentEndText--></style>$}, "Test 26");
+like($Res, qr[^<style><!--${CommentStartText}em\{color:red}$CommentEndText--></style>$], "Test 26");
 
 $H = <<EOF;
 <style>\@import url(&#34;style.css&#34;);</style>
@@ -597,14 +597,14 @@ like($Res, qr{25:<a style="s5\{aa:ab\}s6\{ac:ad\}">}s, "Test style attribute - m
 like($Res, qr{26:<a style=" s7  \{   ae    :     af      \}       s8        \{         ag          :           ah            \}             ">}s, "Test style attribute - multiple property pairs with selectors, braces and spaces but without semi-colon");
 like($Res, qr{27:<a style="s5\{ai:aj;\}s6\{ak:al;\}">}s, "Test style attribute - multiple property pairs with selectors, braces and semi-colon but without spaces");
 like($Res, qr{28:<a style=" s7  \{   am    :     an      \}       s8        \{         ao          :           ap            ;             \}              ">}s, "Test style attribute - multiple property pairs with selectors, braces spaces and semi-colon");
-like($Res, qr{29:<a style="{color: #900} :link {background: #ff0} :visited {background: #fff} :hover {outline: thin red solid} :active {background: #00f}">}s, "Test style attribute - style rule with and without selectors");
-like($Res, qr{30:<a style="{color: #090; line-height: 1.2} ::first-letter {color: #900}">}, "Test style attribute - style rule with and without selectors in single line");
-like($Res, qr{31:<a href="abccomscript" title="a" id="a1" style="{color: #900}
-          :link {background: #ff0}
-          :visited {background: #fff}
-          :hover {outline: thin red solid}
-          :active {background: #00f}">
-$}, "Test style attribute - style rule with and without selectors over multiple lines");
+like($Res, qr[29:<a style="\{color: #900} :link \{background: #ff0} :visited \{background: #fff} :hover \{outline: thin red solid} :active \{background: #00f}">]s, "Test style attribute - style rule with and without selectors");
+like($Res, qr[30:<a style="\{color: #090; line-height: 1.2} ::first-letter \{color: #900}">], "Test style attribute - style rule with and without selectors in single line");
+like($Res, qr[31:<a href="abccomscript" title="a" id="a1" style="\{color: #900}
+          :link \{background: #ff0}
+          :visited \{background: #fff}
+          :hover \{outline: thin red solid}
+          :active \{background: #00f}">
+$], "Test style attribute - style rule with and without selectors over multiple lines");
 
 $H = <<EOF;
 <style>   
@@ -623,19 +623,19 @@ selector5{ab:cd;x:y;p:q;r:url(http://a.com);e:url("http://b.com") ;}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{<style><!--${CommentStartText}   
+like($Res, qr[<style><!--${CommentStartText}   
 
-selector1{ab:cd}
-selector2{ab:cd;}
-selector3{ab:cd;ef:gh}
-selector4{ab:cd;ef:gh;}
-selector5{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/}
- selector6  {   ab    :     cd      }       
- selector7  {   ab    :     cd      ;       }        
- selector8  {   ab    :     cd      ;       ef        :         gh          }           
- selector9  {   ab    :     cd      ;       ef        :         gh          ;           }            
- selector10  {   ab    :     cd      ;       x         :         y           ;           /\*r            :             url\(http://a.com\)              \*/}               
-    $CommentEndText--></style>}s, "Test style tag css with and without spaces");
+selector1\{ab:cd}
+selector2\{ab:cd;}
+selector3\{ab:cd;ef:gh}
+selector4\{ab:cd;ef:gh;}
+selector5\{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/}
+ selector6  \{   ab    :     cd      }       
+ selector7  \{   ab    :     cd      ;       }        
+ selector8  \{   ab    :     cd      ;       ef        :         gh          }           
+ selector9  \{   ab    :     cd      ;       ef        :         gh          ;           }            
+ selector10  \{   ab    :     cd      ;       x         :         y           ;           /\*r            :             url\(http://a.com\)              \*/}               
+    $CommentEndText--></style>]s, "Test style tag css with and without spaces");
 
 $H = <<EOF;
 <style>
@@ -649,14 +649,14 @@ body {color: black}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style>
+like($Res, qr[^<style>
 
 <!--${CommentStartText}
 
-body {color: black}
+body \{color: black}
 
 $CommentEndText-->  
-</style>$}s, "Style tag with HTML comments");
+</style>$]s, "Style tag with HTML comments");
 
 $H = <<EOF;
 <style>
@@ -665,7 +665,7 @@ body {color: black}
 EOF
 $Res = $Defang->defang($H);
 
-like($Res, qr{^<style><!--${CommentStartText}
-body {color: black}
-$CommentEndText--></style>$}s, "Style tag without HTML comments");
+like($Res, qr[^<style><!--${CommentStartText}
+body \{color: black}
+$CommentEndText--></style>$]s, "Style tag without HTML comments");
 
diff --git a/t/04_imports.t b/t/04_imports.t
index 144b09b..01c07bf 100644
--- a/t/04_imports.t
+++ b/t/04_imports.t
@@ -167,7 +167,7 @@ $H = <<EOF;
 <style>em{color:red};\@import url(&#34;style.css&#34;);</style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^<style><!--${CommentStartText}em{color:red}${CommentEndText}--></style>$}, "Test 26");
+like($Res, qr[^<style><!--${CommentStartText}em\{color:red}${CommentEndText}--></style>$], "Test 26");
 
 $H = <<EOF;
 <style>\@import url(&#34;style.css&#34;);</style>
diff --git a/t/05_callbacks.t b/t/05_callbacks.t
index 59d23a8..d955331 100644
--- a/t/05_callbacks.t
+++ b/t/05_callbacks.t
@@ -522,7 +522,7 @@ selector5{ab:cd;x:y;p:q;r:url(http://a.com);e:url("http://b.com") ;}
     </style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^1:<a style="a:b">
+like($Res, qr[^1:<a style="a:b">
 2:<a style=" c  :   d    ">
 3:<a style="e:f;">
 4:<a style=" g  :   h    ;     ">
@@ -532,51 +532,51 @@ like($Res, qr{^1:<a style="a:b">
 7:<a style="i3:j3;k3:l3;">
 8:<a style=" i4  :   j4    ;     k4      :       l4        ;         ">
 
-9:<a style="{q:r}">
-10:<a style=" {  s   :    t     }      ">
-11:<a style="{u:v;}">
-12:<a style=" {  w   :    x     ;      }       ">
-
-13:<a style="{i5:j5;k5:l5}">
-14:<a style=" {  i6   :    j6     ;      k6       :        l6         }          ">
-15:<a style="{i7:j7;k7:l7;}">
-16:<a style=" {  i8   :    j8     ;      k8       :        l8         ;          }          ">
-
-17:<a style="s1{y:z}">
-18:<a style=" s1  {   y2    :     z2      }       ">
-19:<a style="s1{y3:z3;}">
-20:<a style=" s1  {   y4    :     z4      ;       }        ">
-
-21:<a style="s1{y5:z5;y6:z6}">
-22:<a style=" s2  {   y7    :     z7      ;       y8        :         z8          }           ">
-23:<a style="s3{y9:z9;y10:z11;}">
-24:<a style=" s4  {   y12    :     z12      ;       y13        :         z13          ;           }            ">
-
-25:<a style="s5{aa:ab}s6{ac:ad}">
-26:<a style=" s7  {   ae    :     af      }       s8        {         ag          :           ah            }             ">
-27:<a style="s5{ai:aj;}s6{ak:al;}">
-28:<a style=" s7  {   am    :     an      }       s8        {         ao          :           ap            ;             }              ">
-
-29:<a style="{color: #900} :link {background: #ff0} :visited {background: #fff} :hover {outline: thin red solid} :active {background: #00f}">
-30:<a style="{color: #090; line-height: 1.2} ::first-letter {color: #900}">
-31:<a href="abccomscript" title="a" id="a1" style="{color: #900}
-          :link {background: #ff0}
-          :visited {background: #fff}
-          :hover {outline: thin red solid}
-          :active {background: #00f}">
+9:<a style="\{q:r}">
+10:<a style=" \{  s   :    t     }      ">
+11:<a style="\{u:v;}">
+12:<a style=" \{  w   :    x     ;      }       ">
+
+13:<a style="\{i5:j5;k5:l5}">
+14:<a style=" \{  i6   :    j6     ;      k6       :        l6         }          ">
+15:<a style="\{i7:j7;k7:l7;}">
+16:<a style=" \{  i8   :    j8     ;      k8       :        l8         ;          }          ">
+
+17:<a style="s1\{y:z}">
+18:<a style=" s1  \{   y2    :     z2      }       ">
+19:<a style="s1\{y3:z3;}">
+20:<a style=" s1  \{   y4    :     z4      ;       }        ">
+
+21:<a style="s1\{y5:z5;y6:z6}">
+22:<a style=" s2  \{   y7    :     z7      ;       y8        :         z8          }           ">
+23:<a style="s3\{y9:z9;y10:z11;}">
+24:<a style=" s4  \{   y12    :     z12      ;       y13        :         z13          ;           }            ">
+
+25:<a style="s5\{aa:ab}s6\{ac:ad}">
+26:<a style=" s7  \{   ae    :     af      }       s8        \{         ag          :           ah            }             ">
+27:<a style="s5\{ai:aj;}s6\{ak:al;}">
+28:<a style=" s7  \{   am    :     an      }       s8        \{         ao          :           ap            ;             }              ">
+
+29:<a style="\{color: #900} :link \{background: #ff0} :visited \{background: #fff} :hover \{outline: thin red solid} :active \{background: #00f}">
+30:<a style="\{color: #090; line-height: 1.2} ::first-letter \{color: #900}">
+31:<a href="abccomscript" title="a" id="a1" style="\{color: #900}
+          :link \{background: #ff0}
+          :visited \{background: #fff}
+          :hover \{outline: thin red solid}
+          :active \{background: #00f}">
 <style><!--${CommentStartText}   
 
-selector1{ab:cd}
-selector2{ab:cccd;}
-selector3{ab:cd;ef:gh}
-selector4{ab:cd;ef:gh;}
-selector5{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/}
- selector6  {   ab    :     cd      }       
- selector7  {   ab    :     cd      ;       }        
- selector8  {   ab    :     cd      ;       ef        :         gh          }           
- selector9  {   ab    :     cd      ;       ef        :         gh          ;           }            
- selector10  {   ab    :     cd      ;       x         :         y           ;           /\*r            :             url\(http://a.com\)              \*/}               
-    ${CommentEndText}--></style>$}, "CSS callback - force normal");
+selector1\{ab:cd}
+selector2\{ab:cccd;}
+selector3\{ab:cd;ef:gh}
+selector4\{ab:cd;ef:gh;}
+selector5\{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/}
+ selector6  \{   ab    :     cd      }       
+ selector7  \{   ab    :     cd      ;       }        
+ selector8  \{   ab    :     cd      ;       ef        :         gh          }           
+ selector9  \{   ab    :     cd      ;       ef        :         gh          ;           }            
+ selector10  \{   ab    :     cd      ;       x         :         y           ;           /\*r            :             url\(http://a.com\)              \*/}               
+    ${CommentEndText}--></style>$], "CSS callback - force normal");
 
 $Defang = HTML::Defang->new(
   css_callback => sub {
@@ -649,7 +649,7 @@ selector5{ab:cd;x:y;p:q;r:url(http://a.com);e:url("http://b.com") ;}
     </style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^1:<a style="a:b">
+like($Res, qr[^1:<a style="a:b">
 2:<a style=" c  :   d    ">
 3:<a style="e:f;">
 4:<a style=" g  :   h    ;     ">
@@ -659,51 +659,51 @@ like($Res, qr{^1:<a style="a:b">
 7:<a style="i3:j3;k3:l3;">
 8:<a style=" i4  :   j4    ;     k4      :       l4        ;         ">
 
-9:<a style="{q:r}">
-10:<a style=" {  s   :    t     }      ">
-11:<a style="{u:v;}">
-12:<a style=" {  w   :    x     ;      }       ">
-
-13:<a style="{i5:j5;k5:l5}">
-14:<a style=" {  i6   :    j6     ;      k6       :        l6         }          ">
-15:<a style="{i7:j7;k7:l7;}">
-16:<a style=" {  i8   :    j8     ;      k8       :        l8         ;          }          ">
-
-17:<a style="s1{y:z}">
-18:<a style=" s1  {   y2    :     z2      }       ">
-19:<a style="s1{y3:z3;}">
-20:<a style=" s1  {   y4    :     z4      ;       }        ">
-
-21:<a style="s1{y5:z5;y6:z6}">
-22:<a style=" s2  {   y7    :     z7      ;       y8        :         z8          }           ">
-23:<a style="s3{y9:z9;y10:z11;}">
-24:<a style=" s4  {   y12    :     z12      ;       y13        :         z13          ;           }            ">
-
-25:<a style="s5{aa:ab}s6{ac:ad}">
-26:<a style=" s7  {   ae    :     af      }       s8        {         ag          :           ah            }             ">
-27:<a style="s5{ai:aj;}s6{ak:al;}">
-28:<a style=" s7  {   am    :     an      }       s8        {         ao          :           ap            ;             }              ">
-
-29:<a style="{color: #900} :link {background: #ff0} :visited {background: #fff} :hover {outline: thin red solid} :active {background: #00f}">
-30:<a style="{color: #090; line-height: 1.2} ::first-letter {color: #900}">
-31:<a href="abccomscript" title="a" id="a1" style="{color: #900}
-          :link {background: #ff0}
-          :visited {background: #fff}
-          :hover {outline: thin red solid}
-          :active {background: #00f}">
+9:<a style="\{q:r}">
+10:<a style=" \{  s   :    t     }      ">
+11:<a style="\{u:v;}">
+12:<a style=" \{  w   :    x     ;      }       ">
+
+13:<a style="\{i5:j5;k5:l5}">
+14:<a style=" \{  i6   :    j6     ;      k6       :        l6         }          ">
+15:<a style="\{i7:j7;k7:l7;}">
+16:<a style=" \{  i8   :    j8     ;      k8       :        l8         ;          }          ">
+
+17:<a style="s1\{y:z}">
+18:<a style=" s1  \{   y2    :     z2      }       ">
+19:<a style="s1\{y3:z3;}">
+20:<a style=" s1  \{   y4    :     z4      ;       }        ">
+
+21:<a style="s1\{y5:z5;y6:z6}">
+22:<a style=" s2  \{   y7    :     z7      ;       y8        :         z8          }           ">
+23:<a style="s3\{y9:z9;y10:z11;}">
+24:<a style=" s4  \{   y12    :     z12      ;       y13        :         z13          ;           }            ">
+
+25:<a style="s5\{aa:ab}s6\{ac:ad}">
+26:<a style=" s7  \{   ae    :     af      }       s8        \{         ag          :           ah            }             ">
+27:<a style="s5\{ai:aj;}s6\{ak:al;}">
+28:<a style=" s7  \{   am    :     an      }       s8        \{         ao          :           ap            ;             }              ">
+
+29:<a style="\{color: #900} :link \{background: #ff0} :visited \{background: #fff} :hover \{outline: thin red solid} :active \{background: #00f}">
+30:<a style="\{color: #090; line-height: 1.2} ::first-letter \{color: #900}">
+31:<a href="abccomscript" title="a" id="a1" style="\{color: #900}
+          :link \{background: #ff0}
+          :visited \{background: #fff}
+          :hover \{outline: thin red solid}
+          :active \{background: #00f}">
 <style><!--${CommentStartText}   
 
-selector1{ab:cd}
-selector2{ab:cccd;}
-selector3{ab:cd;ef:gh}
-selector4{ab:cd;ef:gh;}
-selector5{ab:cd;x:y;p:q;r:url\(http://a.com\);e:url\("http://b.com"\) ;}
- selector6  {   ab    :     cd      }       
- selector7  {   ab    :     cd      ;       }        
- selector8  {   ab    :     cd      ;       ef        :         gh          }           
- selector9  {   ab    :     cd      ;       ef        :         gh          ;           }            
- selector10  {   ab    :     cd      ;       x         :         y           ;           r            :             url\(http://a.com\)              }               
-    ${CommentEndText}--></style>$}, "CSS callback - force skip");
+selector1\{ab:cd}
+selector2\{ab:cccd;}
+selector3\{ab:cd;ef:gh}
+selector4\{ab:cd;ef:gh;}
+selector5\{ab:cd;x:y;p:q;r:url\(http://a.com\);e:url\("http://b.com"\) ;}
+ selector6  \{   ab    :     cd      }       
+ selector7  \{   ab    :     cd      ;       }        
+ selector8  \{   ab    :     cd      ;       ef        :         gh          }           
+ selector9  \{   ab    :     cd      ;       ef        :         gh          ;           }            
+ selector10  \{   ab    :     cd      ;       x         :         y           ;           r            :             url\(http://a.com\)              }               
+    ${CommentEndText}--></style>$], "CSS callback - force skip");
 
 $Defang = HTML::Defang->new(
   css_callback => sub {
@@ -776,7 +776,7 @@ selector5{ab:cd;x:y;p:q;r:url(http://a.com);e:url("http://b.com") ;}
     </style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^1:<a style="/\*a:b\*/">
+like($Res, qr[^1:<a style="/\*a:b\*/">
 2:<a style=" /\*c  :   d    \*/">
 3:<a style="/\*e:f;\*/">
 4:<a style=" /\*g  :   h    ;\*/     ">
@@ -786,51 +786,51 @@ like($Res, qr{^1:<a style="/\*a:b\*/">
 7:<a style="/\*i3:j3;\*//\*k3:l3;\*/">
 8:<a style=" /\*i4  :   j4    ;\*/     /\*k4      :       l4        ;\*/         ">
 
-9:<a style="{/\*q:r\*/}">
-10:<a style=" {  /\*s   :    t     \*/}      ">
-11:<a style="{/\*u:v;\*/}">
-12:<a style=" {  /\*w   :    x     ;\*/      }       ">
-
-13:<a style="{/\*i5:j5;\*//\*k5:l5\*/}">
-14:<a style=" {  /\*i6   :    j6     ;\*/      /\*k6       :        l6         \*/}          ">
-15:<a style="{/\*i7:j7;\*//\*k7:l7;\*/}">
-16:<a style=" {  /\*i8   :    j8     ;\*/      /\*k8       :        l8         ;\*/          }          ">
-
-17:<a style="s1{/\*y:z\*/}">
-18:<a style=" s1  {   /\*y2    :     z2      \*/}       ">
-19:<a style="s1{/\*y3:z3;\*/}">
-20:<a style=" s1  {   /\*y4    :     z4      ;\*/       }        ">
-
-21:<a style="s1{/\*y5:z5;\*//\*y6:z6\*/}">
-22:<a style=" s2  {   /\*y7    :     z7      ;\*/       /\*y8        :         z8          \*/}           ">
-23:<a style="s3{/\*y9:z9;\*//\*y10:z11;\*/}">
-24:<a style=" s4  {   /\*y12    :     z12      ;\*/       /\*y13        :         z13          ;\*/           }            ">
-
-25:<a style="s5{/\*aa:ab\*/}s6{/\*ac:ad\*/}">
-26:<a style=" s7  {   /\*ae    :     af      \*/}       s8        {         /\*ag          :           ah            \*/}             ">
-27:<a style="s5{/\*ai:aj;\*/}s6{/\*ak:al;\*/}">
-28:<a style=" s7  {   /\*am    :     an      \*/}       s8        {         /\*ao          :           ap            ;\*/             }              ">
-
-29:<a style="{/\*color: #900\*/} :link {/\*background: #ff0\*/} :visited {/\*background: #fff\*/} :hover {/\*outline: thin red solid\*/} :active {/\*background: #00f\*/}">
-30:<a style="{/\*color: #090;\*/ /\*line-height: 1.2\*/} ::first-letter {/\*color: #900\*/}">
-31:<a href="abccomscript" title="a" id="a1" style="{/\*color: #900\*/}
-          :link {/\*background: #ff0\*/}
-          :visited {/\*background: #fff\*/}
-          :hover {/\*outline: thin red solid\*/}
-          :active {/\*background: #00f\*/}">
+9:<a style="\{/\*q:r\*/}">
+10:<a style=" \{  /\*s   :    t     \*/}      ">
+11:<a style="\{/\*u:v;\*/}">
+12:<a style=" \{  /\*w   :    x     ;\*/      }       ">
+
+13:<a style="\{/\*i5:j5;\*//\*k5:l5\*/}">
+14:<a style=" \{  /\*i6   :    j6     ;\*/      /\*k6       :        l6         \*/}          ">
+15:<a style="\{/\*i7:j7;\*//\*k7:l7;\*/}">
+16:<a style=" \{  /\*i8   :    j8     ;\*/      /\*k8       :        l8         ;\*/          }          ">
+
+17:<a style="s1\{/\*y:z\*/}">
+18:<a style=" s1  \{   /\*y2    :     z2      \*/}       ">
+19:<a style="s1\{/\*y3:z3;\*/}">
+20:<a style=" s1  \{   /\*y4    :     z4      ;\*/       }        ">
+
+21:<a style="s1\{/\*y5:z5;\*//\*y6:z6\*/}">
+22:<a style=" s2  \{   /\*y7    :     z7      ;\*/       /\*y8        :         z8          \*/}           ">
+23:<a style="s3\{/\*y9:z9;\*//\*y10:z11;\*/}">
+24:<a style=" s4  \{   /\*y12    :     z12      ;\*/       /\*y13        :         z13          ;\*/           }            ">
+
+25:<a style="s5\{/\*aa:ab\*/}s6\{/\*ac:ad\*/}">
+26:<a style=" s7  \{   /\*ae    :     af      \*/}       s8        \{         /\*ag          :           ah            \*/}             ">
+27:<a style="s5\{/\*ai:aj;\*/}s6\{/\*ak:al;\*/}">
+28:<a style=" s7  \{   /\*am    :     an      \*/}       s8        \{         /\*ao          :           ap            ;\*/             }              ">
+
+29:<a style="\{/\*color: #900\*/} :link \{/\*background: #ff0\*/} :visited \{/\*background: #fff\*/} :hover \{/\*outline: thin red solid\*/} :active \{/\*background: #00f\*/}">
+30:<a style="\{/\*color: #090;\*/ /\*line-height: 1.2\*/} ::first-letter \{/\*color: #900\*/}">
+31:<a href="abccomscript" title="a" id="a1" style="\{/\*color: #900\*/}
+          :link \{/\*background: #ff0\*/}
+          :visited \{/\*background: #fff\*/}
+          :hover \{/\*outline: thin red solid\*/}
+          :active \{/\*background: #00f\*/}">
 <style><!--${CommentStartText}   
 
-selector1{/\*ab:cd\*/}
-selector2{/\*ab:cccd;\*/}
-selector3{/\*ab:cd;\*//\*ef:gh\*/}
-selector4{/\*ab:cd;\*//\*ef:gh;\*/}
-selector5{/\*ab:cd;\*//\*x:y;\*//\*p:q;\*//\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/}
- selector6  {   /\*ab    :     cd      \*/}       
- selector7  {   /\*ab    :     cd      ;\*/       }        
- selector8  {   /\*ab    :     cd      ;\*/       /\*ef        :         gh          \*/}           
- selector9  {   /\*ab    :     cd      ;\*/       /\*ef        :         gh          ;\*/           }            
- selector10  {   /\*ab    :     cd      ;\*/       /\*x         :         y           ;\*/           /\*r            :             url\(http://a.com\)              \*/}               
-    ${CommentEndText}--></style>}, "CSS callback - force defang");
+selector1\{/\*ab:cd\*/}
+selector2\{/\*ab:cccd;\*/}
+selector3\{/\*ab:cd;\*//\*ef:gh\*/}
+selector4\{/\*ab:cd;\*//\*ef:gh;\*/}
+selector5\{/\*ab:cd;\*//\*x:y;\*//\*p:q;\*//\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/}
+ selector6  \{   /\*ab    :     cd      \*/}       
+ selector7  \{   /\*ab    :     cd      ;\*/       }        
+ selector8  \{   /\*ab    :     cd      ;\*/       /\*ef        :         gh          \*/}           
+ selector9  \{   /\*ab    :     cd      ;\*/       /\*ef        :         gh          ;\*/           }            
+ selector10  \{   /\*ab    :     cd      ;\*/       /\*x         :         y           ;\*/           /\*r            :             url\(http://a.com\)              \*/}               
+    ${CommentEndText}--></style>], "CSS callback - force defang");
 
 $Defang = HTML::Defang->new(
   css_callback => sub {
@@ -901,7 +901,7 @@ selector5{ab:cd;x:y;p:q;r:url(http://a.com);e:url("http://b.com") ;}
     </style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^1:<a style="a:b;orange:juice">
+like($Res, qr[^1:<a style="a:b;orange:juice">
 2:<a style=" c  :   d    ;orange:juice">
 3:<a style="e:f;orange:juice">
 4:<a style=" g  :   h    ;     orange:juice">
@@ -911,51 +911,51 @@ like($Res, qr{^1:<a style="a:b;orange:juice">
 7:<a style="i3:j3;k3:l3;orange:juice">
 8:<a style=" i4  :   j4    ;     k4      :       l4        ;         orange:juice">
 
-9:<a style="{q:r;orange:juice}">
-10:<a style=" {  s   :    t     ;orange:juice}      ">
-11:<a style="{u:v;orange:juice}">
-12:<a style=" {  w   :    x     ;      orange:juice}       ">
-
-13:<a style="{i5:j5;k5:l5;orange:juice}">
-14:<a style=" {  i6   :    j6     ;      k6       :        l6         ;orange:juice}          ">
-15:<a style="{i7:j7;k7:l7;orange:juice}">
-16:<a style=" {  i8   :    j8     ;      k8       :        l8         ;          orange:juice}          ">
-
-17:<a style="s1{y:z;orange:juice}">
-18:<a style=" s1  {   y2    :     z2      ;orange:juice}       ">
-19:<a style="s1{y3:z3;orange:juice}">
-20:<a style=" s1  {   y4    :     z4      ;       orange:juice}        ">
-
-21:<a style="s1{y5:z5;y6:z6;orange:juice}">
-22:<a style=" s2  {   y7    :     z7      ;       y8        :         z8          ;orange:juice}           ">
-23:<a style="s3{y9:z9;y10:z11;orange:juice}">
-24:<a style=" s4  {   y12    :     z12      ;       y13        :         z13          ;           orange:juice}            ">
-
-25:<a style="s5{aa:ab;orange:juice}s6{ac:ad;orange:juice}">
-26:<a style=" s7  {   ae    :     af      ;orange:juice}       s8        {         ag          :           ah            ;orange:juice}             ">
-27:<a style="s5{ai:aj;orange:juice}s6{ak:al;orange:juice}">
-28:<a style=" s7  {   am    :     an      ;orange:juice}       s8        {         ao          :           ap            ;             orange:juice}              ">
-
-29:<a style="{color: #900;orange:juice} :link {background: #ff0;orange:juice} :visited {background: #fff;orange:juice} :hover {outline: thin red solid;orange:juice} :active {background: #00f;orange:juice}">
-30:<a style="{color: #090; line-height: 1.2;orange:juice} ::first-letter {color: #900;orange:juice}">
-31:<a href="abccomscript" title="a" id="a1" style="{color: #900;orange:juice}
-          :link {background: #ff0;orange:juice}
-          :visited {background: #fff;orange:juice}
-          :hover {outline: thin red solid;orange:juice}
-          :active {background: #00f;orange:juice}">
+9:<a style="\{q:r;orange:juice}">
+10:<a style=" \{  s   :    t     ;orange:juice}      ">
+11:<a style="\{u:v;orange:juice}">
+12:<a style=" \{  w   :    x     ;      orange:juice}       ">
+
+13:<a style="\{i5:j5;k5:l5;orange:juice}">
+14:<a style=" \{  i6   :    j6     ;      k6       :        l6         ;orange:juice}          ">
+15:<a style="\{i7:j7;k7:l7;orange:juice}">
+16:<a style=" \{  i8   :    j8     ;      k8       :        l8         ;          orange:juice}          ">
+
+17:<a style="s1\{y:z;orange:juice}">
+18:<a style=" s1  \{   y2    :     z2      ;orange:juice}       ">
+19:<a style="s1\{y3:z3;orange:juice}">
+20:<a style=" s1  \{   y4    :     z4      ;       orange:juice}        ">
+
+21:<a style="s1\{y5:z5;y6:z6;orange:juice}">
+22:<a style=" s2  \{   y7    :     z7      ;       y8        :         z8          ;orange:juice}           ">
+23:<a style="s3\{y9:z9;y10:z11;orange:juice}">
+24:<a style=" s4  \{   y12    :     z12      ;       y13        :         z13          ;           orange:juice}            ">
+
+25:<a style="s5\{aa:ab;orange:juice}s6\{ac:ad;orange:juice}">
+26:<a style=" s7  \{   ae    :     af      ;orange:juice}       s8        \{         ag          :           ah            ;orange:juice}             ">
+27:<a style="s5\{ai:aj;orange:juice}s6\{ak:al;orange:juice}">
+28:<a style=" s7  \{   am    :     an      ;orange:juice}       s8        \{         ao          :           ap            ;             orange:juice}              ">
+
+29:<a style="\{color: #900;orange:juice} :link \{background: #ff0;orange:juice} :visited \{background: #fff;orange:juice} :hover \{outline: thin red solid;orange:juice} :active \{background: #00f;orange:juice}">
+30:<a style="\{color: #090; line-height: 1.2;orange:juice} ::first-letter \{color: #900;orange:juice}">
+31:<a href="abccomscript" title="a" id="a1" style="\{color: #900;orange:juice}
+          :link \{background: #ff0;orange:juice}
+          :visited \{background: #fff;orange:juice}
+          :hover \{outline: thin red solid;orange:juice}
+          :active \{background: #00f;orange:juice}">
 <style><!--${CommentStartText}   
 
-selector1{ab:cd;orange:juice}
-selector2{ab:cccd;orange:juice}
-selector3{ab:cd;ef:gh;orange:juice}
-selector4{ab:cd;ef:gh;orange:juice}
-selector5{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/orange:juice}
- selector6  {   ab    :     cd      ;orange:juice}       
- selector7  {   ab    :     cd      ;       orange:juice}        
- selector8  {   ab    :     cd      ;       ef        :         gh          ;orange:juice}           
- selector9  {   ab    :     cd      ;       ef        :         gh          ;           orange:juice}            
- selector10  {   ab    :     cd      ;       x         :         y           ;           /\*r            :             url\(http://a.com\)              ;\*/orange:juice}               
-    ${CommentEndText}--></style>$}, "CSS callback - insert attribute");
+selector1\{ab:cd;orange:juice}
+selector2\{ab:cccd;orange:juice}
+selector3\{ab:cd;ef:gh;orange:juice}
+selector4\{ab:cd;ef:gh;orange:juice}
+selector5\{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*//\*e:url\("http://b.com"\) ;\*/orange:juice}
+ selector6  \{   ab    :     cd      ;orange:juice}       
+ selector7  \{   ab    :     cd      ;       orange:juice}        
+ selector8  \{   ab    :     cd      ;       ef        :         gh          ;orange:juice}           
+ selector9  \{   ab    :     cd      ;       ef        :         gh          ;           orange:juice}            
+ selector10  \{   ab    :     cd      ;       x         :         y           ;           /\*r            :             url\(http://a.com\)              ;\*/orange:juice}               
+    ${CommentEndText}--></style>$], "CSS callback - insert attribute");
 
 
 $Defang = HTML::Defang->new(
@@ -1027,7 +1027,7 @@ selector5{ab:cd;x:y;p:q;r:url(http://a.com);e:url("http://b.com") ;}
     </style>
 EOF
 $Res = $Defang->defang($H);
-like($Res, qr{^1:<a style="">
+like($Res, qr[^1:<a style="">
 2:<a style=" ">
 3:<a style="">
 4:<a style=" ">
@@ -1037,51 +1037,51 @@ like($Res, qr{^1:<a style="">
 7:<a style="i3:j3;">
 8:<a style=" i4  :   j4    ;     ">
 
-9:<a style="{}">
-10:<a style=" {}      ">
-11:<a style="{}">
-12:<a style=" {}       ">
-
-13:<a style="{i5:j5;}">
-14:<a style=" {  i6   :    j6     ;      }          ">
-15:<a style="{i7:j7;}">
-16:<a style=" {  i8   :    j8     ;      }          ">
-
-17:<a style="s1{}">
-18:<a style=" s1  {}       ">
-19:<a style="s1{}">
-20:<a style=" s1  {}        ">
-
-21:<a style="s1{y5:z5;}">
-22:<a style=" s2  {   y7    :     z7      ;       }           ">
-23:<a style="s3{y9:z9;}">
-24:<a style=" s4  {   y12    :     z12      ;       }            ">
-
-25:<a style="s5{}s6{}">
-26:<a style=" s7  {}       s8        {}             ">
-27:<a style="s5{}s6{}">
-28:<a style=" s7  {}       s8        {}              ">
-
-29:<a style="{} :link {} :visited {} :hover {} :active {}">
-30:<a style="{color: #090; } ::first-letter {}">
-31:<a href="abccomscript" title="a" id="a1" style="{}
-          :link {}
-          :visited {}
-          :hover {}
-          :active {}">
+9:<a style="\{}">
+10:<a style=" \{}      ">
+11:<a style="\{}">
+12:<a style=" \{}       ">
+
+13:<a style="\{i5:j5;}">
+14:<a style=" \{  i6   :    j6     ;      }          ">
+15:<a style="\{i7:j7;}">
+16:<a style=" \{  i8   :    j8     ;      }          ">
+
+17:<a style="s1\{}">
+18:<a style=" s1  \{}       ">
+19:<a style="s1\{}">
+20:<a style=" s1  \{}        ">
+
+21:<a style="s1\{y5:z5;}">
+22:<a style=" s2  \{   y7    :     z7      ;       }           ">
+23:<a style="s3\{y9:z9;}">
+24:<a style=" s4  \{   y12    :     z12      ;       }            ">
+
+25:<a style="s5\{}s6\{}">
+26:<a style=" s7  \{}       s8        \{}             ">
+27:<a style="s5\{}s6\{}">
+28:<a style=" s7  \{}       s8        \{}              ">
+
+29:<a style="\{} :link \{} :visited \{} :hover \{} :active \{}">
+30:<a style="\{color: #090; } ::first-letter \{}">
+31:<a href="abccomscript" title="a" id="a1" style="\{}
+          :link \{}
+          :visited \{}
+          :hover \{}
+          :active \{}">
 <style><!--${CommentStartText}   
 
-selector1{}
-selector2{}
-selector3{ab:cd;}
-selector4{ab:cd;}
-selector5{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*/}
- selector6  {}       
- selector7  {}        
- selector8  {   ab    :     cd      ;       }           
- selector9  {   ab    :     cd      ;       }            
- selector10  {   ab    :     cd      ;       x         :         y           ;           }               
-    ${CommentEndText}--></style>$}, "CSS callback - remove attribute from style rule end");
+selector1\{}
+selector2\{}
+selector3\{ab:cd;}
+selector4\{ab:cd;}
+selector5\{ab:cd;x:y;p:q;/\*r:url\(http://a.com\);\*/}
+ selector6  \{}       
+ selector7  \{}        
+ selector8  \{   ab    :     cd      ;       }           
+ selector9  \{   ab    :     cd      ;       }            
+ selector10  \{   ab    :     cd      ;       x         :         y           ;           }               
+    ${CommentEndText}--></style>$], "CSS callback - remove attribute from style rule end");
 
 $Defang = HTML::Defang->new(
   css_callback => sub {
@@ -1102,7 +1102,7 @@ EOF
 $Res = $Defang->defang($H);
 like($Res, qr{1:<a STYLE="a:b;orange:juice">}, "Style callback attribute in upper case");
 like($Res, qr{2:<a STYLE="A:b;orange:juice">}, "Style callback attribute and style property in upper case");
-like($Res, qr{3:<STYLE><!--${CommentStartText}A {WIDTH: 30;orange:juice}${CommentEndText}--></STYLE>}, "Style callback tag and style property in upper case");
+like($Res, qr[3:<STYLE><!--${CommentStartText}A \{WIDTH: 30;orange:juice}${CommentEndText}--></STYLE>], "Style callback tag and style property in upper case");
 
 #################################
 #  Multiple callback test
diff --git a/t/06_unicode.t b/t/06_unicode.t
index d0a783e..e699ebb 100644
--- a/t/06_unicode.t
+++ b/t/06_unicode.t
@@ -51,5 +51,5 @@ $Res = $Defang->defang($H);
 ok(Encode::is_utf8($Res), "output2 is unicode");
 like($Res, qr{^<!--defang_p-->岡<!--/defang_p-->}, "defang2 preserves unicode");
 like($Res, qr{^<!--defang_a defang_href="http://blah\.com/ø" defang_class="û"-->non-english href<!--/defang_a-->}m, "defang2 preserves unicode2");
-like($Res, qr(^<style><!--a { /\*color:redû;\*/ }--></style>)m, "style unicode correct");
+like($Res, qr(^<style><!--a \{ /\*color:redû;\*/ }--></style>)m, "style unicode correct");
 
-- 
2.6.4

