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

Uncaught error when evaluating improper level formula, causing the page to break #3

Closed
SKevo18 opened this issue Aug 7, 2024 · 2 comments
Assignees

Comments

@SKevo18
Copy link

SKevo18 commented Aug 7, 2024

while (n < eval(levelFormula.replace('[level]', n))) {

The use of eval here is unsafe (XSS, etc.). The evaluation will fail if the formula is not defined properly, causing the page to break. I recommend that you apply error handling to this part of the code, ensure that all the inputs contain the necessary variables that need to be replaced, or even better, not use raw eval at all (although I understand that finding a suitable replacement without introducing too much complexity to the existing code is not ideal).

@FoskyM
Copy link
Owner

FoskyM commented Aug 7, 2024

Okay. I'll try to handle the error if available. And adding a verification for the formula input seems to be a good choice as well?

This extension was first made for myself. Though I know that eval is unsafe actually, but as you said, I can't find a suitable alternative until now.

Thanks!

@FoskyM FoskyM self-assigned this Aug 7, 2024
@SKevo18
Copy link
Author

SKevo18 commented Aug 8, 2024

Thank you for your response, I understand :)
Decided to report this, as couple of users occasionally run into this issue at FreeFlarum and don't know what to do because their forum breaks for no apparent reason (so some error handling would definitely be nice so that the page may continue loading)

@FoskyM FoskyM closed this as completed Aug 14, 2024
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

2 participants