1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Improve Journey compliance to RFC 3986

The scanner in Journey fails to recognize routes that use literals
from the sub-delims section of RFC 3986.

This commit enhance the compatibility of Journey with the RFC by
adding support of authorized delimiters to the scanner.

Fix #17212
This commit is contained in:
Nicolas Cavigneaux 2014-10-09 15:06:26 +02:00
parent 5a5073301c
commit 3041bb2a94
3 changed files with 34 additions and 11 deletions

View file

@ -1,3 +1,13 @@
* Improve Journey compliance to RFC 3986
The scanner in Journey failed to recognize routes that use literals
from the sub-delims section of RFC 3986. It's now able to parse those
authorized delimiters and route as expected.
Fixes #17212
*Nicolas Cavigneaux*
* Deprecate implicit Array conversion for Response objects. It was added
(using `#to_ary`) so we could conveniently use implicit splatting:

View file

@ -39,18 +39,18 @@ module ActionDispatch
[:SLASH, text]
when text = @ss.scan(/\*\w+/)
[:STAR, text]
when text = @ss.scan(/\(/)
when text = @ss.scan(/(?<!\\)\(/)
[:LPAREN, text]
when text = @ss.scan(/\)/)
when text = @ss.scan(/(?<!\\)\)/)
[:RPAREN, text]
when text = @ss.scan(/\|/)
[:OR, text]
when text = @ss.scan(/\./)
[:DOT, text]
when text = @ss.scan(/:\w+/)
when text = @ss.scan(/(?<!\\):\w+/)
[:SYMBOL, text]
when text = @ss.scan(/[\w%\-~]+/)
[:LITERAL, text]
when text = @ss.scan(/(?:[\w%\-~!$&'*+,;=@]|\\:|\\\(|\\\))+/)
[:LITERAL, text.gsub('\\', '')]
# any char
when text = @ss.scan(/./)
[:LITERAL, text]

View file

@ -14,6 +14,19 @@ module ActionDispatch
['/', [[:SLASH, '/']]],
['*omg', [[:STAR, '*omg']]],
['/page', [[:SLASH, '/'], [:LITERAL, 'page']]],
['/page!', [[:SLASH, '/'], [:LITERAL, 'page!']]],
['/page$', [[:SLASH, '/'], [:LITERAL, 'page$']]],
['/page&', [[:SLASH, '/'], [:LITERAL, 'page&']]],
["/page'", [[:SLASH, '/'], [:LITERAL, "page'"]]],
['/page*', [[:SLASH, '/'], [:LITERAL, 'page*']]],
['/page+', [[:SLASH, '/'], [:LITERAL, 'page+']]],
['/page,', [[:SLASH, '/'], [:LITERAL, 'page,']]],
['/page;', [[:SLASH, '/'], [:LITERAL, 'page;']]],
['/page=', [[:SLASH, '/'], [:LITERAL, 'page=']]],
['/page@', [[:SLASH, '/'], [:LITERAL, 'page@']]],
['/page\:', [[:SLASH, '/'], [:LITERAL, 'page:']]],
['/page\(', [[:SLASH, '/'], [:LITERAL, 'page(']]],
['/page\)', [[:SLASH, '/'], [:LITERAL, 'page)']]],
['/~page', [[:SLASH, '/'], [:LITERAL, '~page']]],
['/pa-ge', [[:SLASH, '/'], [:LITERAL, 'pa-ge']]],
['/:page', [[:SLASH, '/'], [:SYMBOL, ':page']]],