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

Regex #46

Closed
bleonard opened this issue Jan 4, 2013 · 6 comments
Closed

Regex #46

bleonard opened this issue Jan 4, 2013 · 6 comments

Comments

@bleonard
Copy link

bleonard commented Jan 4, 2013

Just looking at the code as I'm doing something similar
There's a regex here

/ secure;/

I'm pretty sure it should be

/; secure/

As the current case does not handle secure being the last piece of the header.
Maybe it's not an issue in how rack or rails does things, but it seems like you could end up with it there twice.

@rymai
Copy link
Collaborator

rymai commented Jan 6, 2013

Hi, thanks.

I don't think your proposal would handle secure being the first piece of the header, though.

I think /(;\s+)?secure/ would be better to handle all the cases, wdyt?

@bleonard
Copy link
Author

bleonard commented Jan 7, 2013

i've never seen it first, but I have seen it last. it's usually the name, first. I think your regex might be not be good on cookies named "secure" or "secure_anything".
I suppose /(^|;\s)secure[$;]/ might be closer.

@rymai
Copy link
Collaborator

rymai commented Jan 7, 2013

Good point!

I think this would be even better then: (;\s+)?secure($|;) (and works as expected, as shown here).

tobmatth pushed a commit that referenced this issue Jan 9, 2013
@tobmatth
Copy link
Owner

tobmatth commented Jan 9, 2013

Thank you guys, i decided to go with @rymai's last proposal...

@tobmatth tobmatth closed this as completed Jan 9, 2013
@bleonard
Copy link
Author

Sorry, missed this comment. WIthout doingt the beginning of line, that regex has an issue if the value ends in the string secure
http://rubular.com/r/miVoJAVpDl

Mine didn't match just secure on the line but i don't think that's valid
http://rubular.com/r/JYaImKwmKz

@rymai
Copy link
Collaborator

rymai commented Jan 10, 2013

Sorry, you're right, the following Regex should be more rock-solid: http://rubular.com/r/aGG9VYAWFM

Do you think it's ok with this one?

@rymai rymai reopened this Jan 10, 2013
@rymai rymai closed this as completed in c4674cd Apr 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants