Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Journey scanner fails to recognise sub-delims pchars #17212

Closed
pixeltrix opened this issue Oct 8, 2014 · 6 comments · Fixed by #17220
Closed

Journey scanner fails to recognise sub-delims pchars #17212

pixeltrix opened this issue Oct 8, 2014 · 6 comments · Fixed by #17220
Assignees
Milestone

Comments

@pixeltrix
Copy link
Contributor

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

# config/routes.rb
get '/boom!', to: 'boom#bang' as: :boom_bang

# app/controllers/boom_controller.rb
class BoomController < ApplicationController
  def bang; render text: 'bang!'; end
end
>> app.get('/boom!')
=> 404

The simple solution is to add the additional chars to the regexp in the scanner but there's the issue that : and () are in the sub-delims so we should probably allow their use via escaping and to do that I think we need to change the behaviour of a :LITERAL node.

@tenderlove any comments/suggestions?

@pixeltrix pixeltrix self-assigned this Oct 8, 2014
@pixeltrix pixeltrix added this to the 4.2.0 milestone Oct 8, 2014
@tenderlove
Copy link
Member

The simple solution is to add the additional chars to the regexp in the scanner but there's the issue that : and () are in the sub-delims so we should probably allow their use via escaping and to do that I think we need to change the behaviour of a :LITERAL node.

Yep. We just need to change the scanner.

@Bounga
Copy link
Contributor

Bounga commented Oct 9, 2014

Just created a PR to fix this issue in Journey. The "(" and ")" cases are not handled since I was not sure of how to do it nicely.

Bounga added a commit to Bounga/rails that referenced this issue Oct 14, 2014
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 rails#17212
@Bounga
Copy link
Contributor

Bounga commented Oct 14, 2014

PR now provide compatibility with all sub-delims listed in RFC

@heathd
Copy link

heathd commented Aug 12, 2015

Hello,

we have noticed that this change has lead to a change in behaviour of routing. It's a bit of an edge case which wasn't documented, so I'm just noting this here in case others encounter the same issue.

in rails 4.1.11 the route '/page*foo' is tokenised as [[:SLASH, "/"], [:LITERAL, "page"], [:STAR, "*foo”]]
wheras in rails 4.2.3 the same route is tokenised as [[:SLASH, '/'], [:LITERAL, 'page*foo']]

Therefore it's no longer possible to use the 'wildcard segment' matching except at the start of a url or a / path separator.

We are relying on this behaviour in a current rails 4.1.11 app, you can see the routing code here https://github.com/alphagov/content-store/blob/master/config/routes.rb

Since this functionality was undocumented, I don't feel like this should be considered a regression.

However, I wonder if it would be valuable to characterise this behaviour in a test case. I'd be happy to submit a PR for that if others think it would be a good idea?

Thanks

David

@pixeltrix
Copy link
Contributor Author

@heathd no, I'd still consider this a regression how ever much of an edge case this is - I'll have a look at it.

@heathd
Copy link

heathd commented Aug 12, 2015

@pixeltrix ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants