<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -117,31 +117,28 @@ class CGI {
         # RAKUDO: This could also be rewritten as a single .subst :g call.
         #         ...when the semantics of .subst is revised to change $/,
         #         that is.
-        # PARROT BUG: TT #752
-        # (https://trac.parrot.org/parrot/ticket/752)
-        # otherwise the solution is just .subst with a call to decode_urle...
-        my $buff = '';
-        my $more = 0;
-        my @chars;
-        for $string.comb -&gt; $c {
-            if $c eq '%' { $buff ~= $c  ; $more=2 ; next }
-            if $more     { $buff ~= $c  ; $more-- ; next }
-            if $buff     { @chars.push: decode_urlencoded_utf8($buff); $buff='' }
-            @chars.push: $c;
+        # The percent_hack can be removed once the bug is fixed and :g is
+        # added
+        while $string ~~ / ( [ '%' &lt;[0..9A..F]&gt;**2 ]+ ) / {
+            $string .= subst( ~$0,
+            percent_hack_start( decode_urlencoded_utf8( ~$0 ) ) );
         }
-        @chars.push: decode_urlencoded_utf8($buff) if $buff;
-
-        # This is the evil hack, we can't join our decoded chars, we have to
-        # write them to a file so they all get the same encoding and charset
-        my $file_name = '/tmp/friggin_decode_problem';
-        my $fh = open($file_name, :w);
-        $fh.print(@chars);
-        $fh.close;
-        return slurp( $file_name );
+        return percent_hack_end( $string );
+    }
+
+    sub percent_hack_start($str is rw) {
+        if $str ~~ '%' {
+            $str = '___PERCENT_HACK___';
+        }
+        return $str;
+    }
+
+    sub percent_hack_end($str) {
+        return $str.subst('___PERCENT_HACK___', '%', :g);
     }
 
     sub decode_urlencoded_utf8($str) {
-        my @returns = ();
+        my $r = '';
         my @chars = map { :16($_) }, $str.split('%').grep({$^w});
         while @chars {
             my $bytes = 1;
@@ -153,10 +150,9 @@ class CGI {
             }
             my @shift = (^$bytes).reverse.map(**6);
             my @mask  = $mask, 0x3F xx $bytes-1;
-            @returns.push: 
-                chr( [+] @chars.splice(0,$bytes) &#187;+&amp;&#171; @mask &#187;+&lt;&#171; @shift );
+            $r ~= chr( [+] @chars.splice(0,$bytes) &#187;+&amp;&#171; @mask &#187;+&lt;&#171; @shift );
         }
-        return @returns;
+        return $r;
     }
 
     method add_param ( Str $key, $value ) {</diff>
      <filename>lib/CGI.pm</filename>
    </modified>
    <modified>
      <diff>@@ -4,17 +4,28 @@ use Test;
 use CGI;
 
 my @t =
-    '%61'       =&gt; 'a',
-    '%C3%A5'    =&gt; '&#229;',
-    '%C4%AC'    =&gt; '&#300;',
-    '%C7%82'    =&gt; '&#450;',
-    '%E2%98%BA' =&gt; '&#9786;',
-    '%E2%98%BB' =&gt; '&#9787;';
+    '%61'                  =&gt; 'a',
+    '%C3%A5'               =&gt; '&#229;',
+    '%C4%AC'               =&gt; '&#300;',
+    '%C7%82'               =&gt; '&#450;',
+    '%E2%98%BA'            =&gt; '&#9786;',
+    '%E2%98%BB'            =&gt; '&#9787;',
+    'alla+snubbar'         =&gt; 'alla snubbar',
+    'text%61+abc'          =&gt; 'texta abc',
+    'unicode+%C7%82%C3%A5' =&gt; 'unicode &#450;&#229;',
+    '%25'                  =&gt; '%',
+    '%25+25'               =&gt; '% 25',
+    '%25rr'                =&gt; '%rr',
+    '%2561'                =&gt; '%61',
+    ;
 
 plan +@t;
 
 for @t {
-    ok( CGI::decode_urlencoded_utf8( .key ) eq .value, 'Decoding ' ~ .key );
+    my $ans = CGI::unescape( ~.key );
+    ok( $ans eq .value, 'Decoding ' ~ .key )
+        or say &quot;GOT: {$ans.perl}\nEXPECTED: {.value.perl}&quot;;
+
 }
 
 # vim: ft=perl6</diff>
      <filename>t/cgi/03-urlencoded.t</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3be6afd61e505a25998b4afa6f6ec4dae945d2f0</id>
    </parent>
  </parents>
  <author>
    <name>Johan Viklund</name>
    <email>johan.viklund@gmail.com</email>
  </author>
  <url>http://github.com/viklund/november/commit/e5984250deb4079b267ef458ff6b4d156beb7727</url>
  <id>e5984250deb4079b267ef458ff6b4d156beb7727</id>
  <committed-date>2009-06-28T10:27:27-07:00</committed-date>
  <authored-date>2009-06-28T10:27:27-07:00</authored-date>
  <message>Removed workaround for Parrot TT #752</message>
  <tree>d0bceb0b14b53498e0cf33f374728a59fc830396</tree>
  <committer>
    <name>Johan Viklund</name>
    <email>johan.viklund@gmail.com</email>
  </committer>
</commit>
