From: John Napiorkowski Date: Mon, 27 Jul 2015 15:32:38 +0000 (-0500) Subject: more tests for escaping fragment X-Git-Tag: 5.90096~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=9d1f95081b5502041ce6597d67a7aa3c23dc8e08 more tests for escaping fragment --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8bdad88..4ef7047 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1670,7 +1670,7 @@ sub uri_for { $args =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go; # re-attach fragment on the end of everything after adding params - $args .= "#$fragment" if $fragment; + $query .= "#$fragment" if $fragment; my $res = bless(\"${base}${args}${query}", $class); $res; diff --git a/t/aggregate/unit_core_uri_for.t b/t/aggregate/unit_core_uri_for.t index d3696a2..453d6e0 100644 --- a/t/aggregate/unit_core_uri_for.t +++ b/t/aggregate/unit_core_uri_for.t @@ -62,9 +62,24 @@ is( is( Catalyst::uri_for( $context, '/bar#fragment', { param1 => 'value1' } )->as_string, 'http://127.0.0.1/foo/bar?param1=value1#fragment', - 'URI for path with fragment and query params' + 'URI for path with fragment and query params 1' ); + +is( + Catalyst::uri_for( $context, '/bar#fragment\x{2620}', { param1 => 'value1' } )->as_string, + 'http://127.0.0.1/foo/bar?param1=value1#fragment%5Cx%7B2620%7D', + 'URI for path with fragment and query params 2' +); + + +is( + Catalyst::uri_for( $context, '/bar#fragment^%$', { param1 => 'value1' } )->as_string, + 'http://127.0.0.1/foo/bar?param1=value1#fragment%5E%25%24', + 'URI for path with fragment and query params 3' +); + + # test with utf-8 is( Catalyst::uri_for( $context, 'quux', { param1 => "\x{2620}" } )->as_string,