Skip to content

Commit

Permalink
Switch uri to RFC3986 by default, match/fix docs.
Browse files Browse the repository at this point in the history
The documentation said 2.26 switched to RFC3986 by default, but it did not;
that "~" would be escaped, but it never has been; and did not document that
'"' would now be correctly escaped.
  • Loading branch information
dracos committed Jan 2, 2018
1 parent 4c602d0 commit b0620f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
#
#========================================================================

#-----------------------------------------------------------------------
# Unreleased
#------------------------------------------------------------------------

* Matthew Somerville switched uri/url to use RFC3986 as per the docs, and
updated the documentation to match the history.
https://github.com/abw/Template2/issues/35


#-----------------------------------------------------------------------
# Version 2.27 - 13th December 2016
#------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions lib/Template/Filters.pm
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ sub _dump {
#-----------------------------------------------------------------------

our $UNSAFE_SPEC = {
RFC2732 => q{A-Za-z0-9\-_.!~*'()},
RFC3986 => q{A-Za-z0-9\-\._~},
RFC2732 => q{A-Za-z0-9\-_.~!*'()},
RFC3986 => q{A-Za-z0-9\-_.~},
};
our $UNSAFE_CHARS = $UNSAFE_SPEC->{ RFC2732 };
our $UNSAFE_CHARS = $UNSAFE_SPEC->{ RFC3986 };
our $URI_REGEX;
our $URL_REGEX;
our $URI_ESCAPES;
Expand Down
11 changes: 7 additions & 4 deletions lib/Template/Manual/Filters.pod
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,14 @@ RFC 2396 specification (since superceded by RFC2732 and RFC3986). So we
fixed it in 2.16 and provided the url filter to implement the old behaviour
of not encoding reserved characters.
As of version 2.26 of the Template Toolkit, the C<uri> and L<url> filters
As of version 2.28 of the Template Toolkit, the C<uri> and L<url> filters
use the unsafe character set defined by RFC3986. This means that certain
characters ("(", ")", "~", "*", "!" and the single quote "'") are now deemed
unsafe and will be escaped as hex character sequences. The double quote
character ('"') is now deemed safe and will not be escaped.
characters ("(", ")", "*", "!", "'", and '"') are now deemed unsafe and
will be escaped as hex character sequences.
The ability to use the RFC3986 character set was added in 2.26 but not
enabled by default; double quote was incorrectly deemed safe in 2.26 but
correctly escaped in 2.27.
If you want to enable the old behaviour then call the C<use_rfc2732()>
method in L<Template::Filters>
Expand Down

0 comments on commit b0620f4

Please sign in to comment.