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:
parent
5a5073301c
commit
3041bb2a94
3 changed files with 34 additions and 11 deletions
|
@ -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:
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -11,12 +11,25 @@ module ActionDispatch
|
|||
# /page/:id(/:action)(.:format)
|
||||
def test_tokens
|
||||
[
|
||||
['/', [[:SLASH, '/']]],
|
||||
['*omg', [[:STAR, '*omg']]],
|
||||
['/page', [[:SLASH, '/'], [:LITERAL, 'page']]],
|
||||
['/~page', [[:SLASH, '/'], [:LITERAL, '~page']]],
|
||||
['/pa-ge', [[:SLASH, '/'], [:LITERAL, 'pa-ge']]],
|
||||
['/:page', [[:SLASH, '/'], [:SYMBOL, ':page']]],
|
||||
['/', [[: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']]],
|
||||
['/(:page)', [
|
||||
[:SLASH, '/'],
|
||||
[:LPAREN, '('],
|
||||
|
|
Loading…
Reference in a new issue