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

Avoid panicking if a bad regexp is returned when hijacking using an incorrect pattern #982

Open
rdelcampog opened this issue Nov 27, 2023 · 3 comments · May be fixed by #983
Open

Avoid panicking if a bad regexp is returned when hijacking using an incorrect pattern #982

rdelcampog opened this issue Nov 27, 2023 · 3 comments · May be fixed by #983

Comments

@rdelcampog
Copy link

rdelcampog commented Nov 27, 2023

Using an incorrect pattern (like **.example.com/**) in the HijackRouter.Add() method will make the program panic instead of returning an error.

Rod Version: v0.114.5

@ysmood
Copy link
Member

ysmood commented Nov 27, 2023

Error is usually used for uncontrolled contents such as user input, panic is usually used for static content.
Usually this regexp pattern is part of the code, so panic is not that unexpected, what do you think?

if it returns the error what would you do with the error?

@codespearhead
Copy link

codespearhead commented Apr 5, 2024

In this context, I'd expect it to raise an error and halt the execution of program.

@ysmood
Copy link
Member

ysmood commented Apr 17, 2024

You can always check the pattern before you pass it to the code.

_, err := regexp.Compile(reg)
if err != nil {
  ...
}

router.Add(reg, ...)

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

Successfully merging a pull request may close this issue.

3 participants