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

Allow UTF-8 in (Query|Request)Param requirements. #311

Closed
borisguery opened this issue Oct 9, 2012 · 3 comments
Closed

Allow UTF-8 in (Query|Request)Param requirements. #311

borisguery opened this issue Oct 9, 2012 · 3 comments

Comments

@borisguery
Copy link
Contributor

Currently, when you set a requirement, you set a pattern which is wrapped in the ParamFetcher which results in some frustration when you need to use complex or localized regex.

Here is an use case:

I've the following QueryParam:

@QueryParam(name="q", requirements="[\p{L}]+", description="Keyword to search for")

The \p escape sequence is used to match unicode characters, the {L} means letter only.

Using this pattern I should be able to match any of the following string:

  • héllo
  • âbçàœñ
  • русский

But it is currently not possible because there are no u flag (pattern modifier).

So, the question is open.

I can think of several solutions:

  • Add the /u flag to the ParamFetcher (may breaks things because an unicode character is several bytes)
  • Remove the auto-magic pattern wrapper and let the user defines the full pattern (can break things)
  • Add an option, like "unicode=true" (only fill the unicode problem) or "flags=ugi"

Any thoughts on this?

@lsmith77
Copy link
Member

lsmith77 commented Nov 7, 2012

good question .. @Seldaek do you have an opinion on this? i would lean towards option 2 .. or maybe a flags attribute.

@borisguery
Copy link
Contributor Author

I think the main advantage of the unicode/flags approach over the full pattern is that it doesn't break things, but a full pattern is obviously the most flexible. We may do some wrapping magic but it may be tricky.

@Seldaek
Copy link
Contributor

Seldaek commented Nov 7, 2012

I am ambivalent because the symfony routing requirements only seem to have the "s" flag set and that's all you get. Here we have "xs" set, which seems kinda wrong. I think I'd be for either having "s" or requiring a full pattern always. Then again "us" seems fine too.

Auto-magic might work though, but indeed it's a dangerous path.

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