Skip to content

Bugfix/inconsistent megasplat split - #1157

Closed
veryrusty wants to merge 4 commits into
masterfrom
bugfix/inconsistent_megasplat_split
Closed

veryrusty wants to merge 4 commits into
masterfrom
bugfix/inconsistent_megasplat_split

Conversation

@veryrusty

Copy link
Copy Markdown
Member

The string that a megasplat matched is split on /. Without setting an LIMIT for the split, empty trailing values get stripped. That is; for the route /foo/**, the paths /foo/bar and /foo/bar/ were both matching and gave the splat as ['bar'].

Or, if there were further trailing slashes in the path:
/foo/bar///a gave ['bar','','','a'] but
/foo/bar/// gave ['bar']. How's that for inconsistent.

Adding a (negative) limit to the split on megasplat values so empty trailing values are kept, which allows you to join the arrayref of values together and get the original path again.

The above examples become:
/foo/bar/ giving ['bar','']

/foo/bar///a giving ['bar','','','a'] #as before

/foo/bar/// giving ['bar','','', '']

This is a subtle change in behaviour, which may cause some Dancers issues if they are not aware of the change.

The string that a megasplat matched is split on '/'. Without setting an
LIMIT for the split, empty trailing values get stripped. That is;
for the route '/foo/**', the paths '/foo/bar' and '/foo/bar/'
were both giving the splat as [ 'bar' ].

Or, if there were further trailing slashes in the path:
'/foo/bar///a'  gave  ['bar','','','a'] but
'/foo/bar///'   gave  ['bar'].   How's that for inconsistent.

Instead, this commit adds a (negative) limit to the split on megasplat
values so that empty trailing values are kept, which allows you to join
the arrayref of values together and get the original path again. The
above examples are:
'/foo/bar/'     giving ['bar','']
'/foo/bar///a'  giving ['bar','','','a']  #as before
'/foo/bar///'   giving ['bar','','','']

This is a subtle change in behaviour, which _may_ cause some Dancers
issues if they are not aware of the change.

Closes #1155.
@veryrusty
veryrusty force-pushed the bugfix/inconsistent_megasplat_split branch from a55c1b9 to 354ee94 Compare April 13, 2016 04:17
@veryrusty

Copy link
Copy Markdown
Member Author

(Updated commit comment - examples need to be correct!)

@xsawyerx

Copy link
Copy Markdown
Member

👍 With a nice reflection of this in the Changes file.

@xsawyerx xsawyerx added the Bug label Apr 13, 2016
@racke

racke commented Apr 13, 2016

Copy link
Copy Markdown
Member

👍 I agree with @xsawyerx

@veryrusty

Copy link
Copy Markdown
Member Author

I'll merge this soon :) Thanks all (and especially to @miyagawa)

@veryrusty

Copy link
Copy Markdown
Member Author

@xsawyerx @racke I've added (a longish) changelog entry for this as a separate commit (edcbccc). Is that what you had in mind ?

@racke

racke commented Apr 13, 2016

Copy link
Copy Markdown
Member

Yeah, I'm just think it is "splitting" instead of "spliting".

@veryrusty

Copy link
Copy Markdown
Member Author

Thanks @racke. Fixed and merged. 👯

@veryrusty veryrusty closed this Apr 13, 2016
@veryrusty
veryrusty deleted the bugfix/inconsistent_megasplat_split branch April 13, 2016 12:55
xsawyerx added a commit that referenced this pull request Apr 19, 2016
    [ BUG FIXES ]
    * GH #1102: Handle multiple '..' in file path utilities.
      (Oleg A. Mamontov, Peter Mottram)
    * GH #1114: Fix missing prereqs as reported by CPANTS.
      (Mohammad S Anwar)
    * GH #1128: Shh warning if optional megasplat is not present.
      (David Precious)
    * GH #1139: Fix incorrect Content-Length header added by AutoPage
      handler (Michael Kröll, Russell Jenkins)
    * GH #1144: Change tt tags to span in skel (Jason Lewis)
    * GH #1046: "no_server_tokens" configuration option doesn't work.
      (Sawyer X)
    # GH #1155, #1157: Fix megasplat value splitting when there are empty
      trailing path segments. (Tatsuhiko Miyagawa, Russell Jenkins)
      NOTE: Paths matching a megasplat that end with a '/' will now include
      an empty string as the last value. For the route pattern '/foo/**',
      the path '/foo/bar', the megasplat gives ['bar'], whereas '/foo/bar/'
      now gives ['bar','']. Joining the array of megasplat values will now
      always be the string matched against for the megasplit.

    [ DOCUMENTATION ]
    * GH #1119: Improve the deployment documentation. (Andrew Beverley)
    * GH #1123: Document import of utf8 pragma. (Victor Adam)
    * GH #1132: Fix spelling mistakes in POD (Gregor Herrmann)
    * GH #1134: Fix spelling errors detected by codespell (James McCoy)
    * GH #1153: Fix POD rendering error. (Sawyer X)

    [ ENHANCEMENTS ]
    * GH #1129: engine.logger.* hooks are called around logging a message.
      (Russell @veryrusty Jenkins)
    * GH #1146: Cleaner display of error context (Vernon Lyon)
    * GH #1085: Add consistent keywords for accessing headers;
      'request_header' for request, 'response_header', 'response_headers'
      and 'push_response_header' for response. (Russell @veryrusty Jenkins)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants