banbuilder icon indicating copy to clipboard operation
banbuilder copied to clipboard

Makes whitelist comparison case-insensitive

Open nick-sturrock opened this issue 6 years ago • 2 comments

Previously whitelisted words would only be accepted if the case matched that used in the configured list

nick-sturrock avatar May 31 '18 14:05 nick-sturrock

Looks like this PR broke the tests. Can you fix that and push again?

snipe avatar May 31 '18 19:05 snipe

Done. This still has some shortcomings that someone with more time (perhaps a future me...) needs to address. There are cases where the original case of the input string is not preserved because of the way the whitelisting replaces all matching parts of the input string with a single placeholder. If the input string contains the same whitelisted word more than once with different capitalisations then all instances of the whitelisted word will end up being replaced with the same capitalisation as the original whitelist entry. Example: 'Pig pIG PIG' with whitelist entry 'pig' becomes 'pig pig pig', because 'Pig', 'pIG' and 'PIG' would all now case-insensitive match 'pig', and the placeholder value in the whitelist transformation would just be 'pig' as the placeholder is taken from the whitelist rather than from the string.

In my use case this doesn't matter as I'm only using the lib to determine whether the content is safe or not - i.e. does the clean string match the original one, but you may want to consider not merging the pull request until a case-safe implementation is added.

nick-sturrock avatar Jun 01 '18 08:06 nick-sturrock