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

Path matching greater than > and lesser than < symbols #263

Open
LokeshNSF opened this issue Nov 30, 2021 · 7 comments
Open

Path matching greater than > and lesser than < symbols #263

LokeshNSF opened this issue Nov 30, 2021 · 7 comments
Labels

Comments

@LokeshNSF
Copy link

LokeshNSF commented Nov 30, 2021

I am trying to match greater than > and lesser than < symbols in the path of Express 4.17.1, but it is not working.
I tried regex match using /[><]/, but it is not matching a path with /test/.

Is there any special handling that we need to do to handle this like how it is for $ where we use ([$])?
Any help here is appreciated.

@blakeembrey
Copy link
Member

A regex is just a regex, but why would [<>] match /test/?

@LokeshNSF
Copy link
Author

A regex is just a regex, but why would [<>] match /test/?

Sorry that was a typo, it was not matching a path with /test/

@blakeembrey
Copy link
Member

That's correct though. There are no characters of >< in /test/.

@LokeshNSF
Copy link
Author

That's correct though. There are no characters of >< in /test/.

I think whatever I am writing is not getting shown (I have added in quotes now sorry :() what I meant was Sorry that was a typo, it was not matching a path with /test/<param>

@LokeshNSF
Copy link
Author

I tried couple of other things too, /(><)/ , /.(><)./, and /.[><]./ but none of these regex are matching this path /test/<param>

@blakeembrey
Copy link
Member

There's probably two issues you're having:

  1. /[><]/ matches because it's a regex, the others you wrote don't make sense. You can test a regex like usual, e.g. /[><]/.exec('/test/<param>').
  2. If you're trying to match this coming from a URL path, < and > are not valid characters and would be URL escaped so matching on < and > is impossible to do, you'd want the URL encoded versions instead

@LokeshNSF
Copy link
Author

Got it, Thanks @blakeembrey. /(%3E|%3C)/ works.

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

No branches or pull requests

3 participants