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
A Broken slur filter regex can stunlock the site #2900
Comments
Hrm, could have sworn we validate that it's okay regex before saving, but maybe not. This is a good first issue. |
I would love some pointers on how to confront that issue |
@makotech222 Could you please provide examples to the pattern which caused this issue? |
excuse the slurs, obviously. |
Slur filter is updated here, so you need to compile the regex from data and return an error if it fails. https://github.com/LemmyNet/lemmy/blob/main/crates/api_crud/src/site/update.rs#L113 |
This happened to me with a very simple filter, and prevented any user from posting on the site or the admins from updating settings to fix it.
Note how the last part of the regex has nothing after the To fix this for my instance, I followed these steps
And this resolved my issue 😄 Hope this helps anyone seeing this in the future I'd suggest prioritizing this issue, since new moderators coming from Reddit in the next few days will probably want to import slur filters and make mistakes while doing so. |
Hi, I tried my hand at this issue and I seem to have gotten a working solution. When testing locally, it's able to read the inputted regex and return an error if it's invalid. This is pretty much my first time writing Rust code so sorry if it's poorly written. Also, I'm not sure what the procedure is for getting this reviewed or if I need to write any tests. Code comparison: Thanks. |
…e along with small validation organization
@ContemporaryArtwork, I'd recommend against using From the
|
@dcormier Yeah, that makes sense. Somehow I missed that part of the docs. |
…hen a regex fails to compile by returning a LemmyError, also returns a LemmyError when the input regex string reference is None (Not sure if that'll ever happen)
A regex that fails to compile gives the following error
Which will prevent people from posting/commenting. Also prevents admins from saving site settings, required admin to make manual changes to db to clear the regex.
The text was updated successfully, but these errors were encountered: