Comments (2)
The error seems to be in the whitelisted term matching logic. In particular, we are using an index into the original input where we should instead be using an index to the transformed input, resulting in the second assa
to be skipped over*. The following diff seems to fix it, if this is urgent for you:
diff --git a/src/matcher/regexp/RegExpMatcher.ts b/src/matcher/regexp/RegExpMatcher.ts
index 7f4fdb1..af31d87 100644
--- a/src/matcher/regexp/RegExpMatcher.ts
+++ b/src/matcher/regexp/RegExpMatcher.ts
@@ -161,7 +161,7 @@ export class RegExpMatcher implements Matcher {
}
matches.insert(indices[startIndex], endIndex);
- lastEnd = endIndex + 1;
+ lastEnd = startIndex + whitelistedTerm.length;
}
}
I will hold off on a patch release until I have time to look at this more carefully, though. The matching logic is fairly complex and I would like to refamiliarize myself with the implementation to ensure this is fully correct first (particularly in cases with non-ASCII characters.) Unfortunately, as I said in #46, this may have to wait until late this month or early February. Apologies.
*I verified that there is no security issue with OOB access due to this mismatch--it should be purely a matter of correctness.
from obscenity.
const input = `
Assamese -> Assam`
Additionally, removing the quotes and leaving just the whitespace (4 spaces on each line) still results in the unexpected censoring. If you delete any of these spaces, no censoring occurs.
from obscenity.
Related Issues (12)
- Question around performance HOT 2
- bug: Unable to ban numbers HOT 6
- bug: Memory leak when using an empty string HOT 2
- Incorrect docs for skipNonAlphabeticTransformer HOT 1
- Fix Typescript Types when using NodeNext module resolution HOT 1
- bug: Certain words not being censored HOT 6
- request: Censor the word "shit" HOT 2
- bug: Censoring of the n-word results in more asterisks than expected HOT 2
- Dependency Dashboard
- bug: Using .addPhrase with Angular script optimization causes error that prevents Angular from bootstrapping HOT 1
- request: French language support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obscenity.