Don't return 500s for books containing non-ASCII fields. #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, trying to run e.g.:
i.e. POST to /books with:
{ "title": "שלום", "genre": "bar", "author": "baz", "yearPublished": 2023 }would blow up with:
This error actually comes from the bad-words library during profanity
filtering, so it can actually be minimized to:
or even purely with JS regexes to:
which just returns
nullbecause\bin JS doesn't cope with non-ASCIIword boundaries.
It seems slightly unlikely that
bad-wordswould want some sort ofpatch for this given it seems to only handle English anyhow (though
might file an issue anyhow in case it feels like at least doing nothing
in this case rather than blowing up).
But here, this patch makes us do the former, i.e. let through any
non-ASCII characters.
The test collection is also updated to make one of the fields actually
trigger this code path.