diff --git a/src/languages/ru/profanity/huy.json b/src/languages/ru/profanity/huy.json index 9822faa..d989f4d 100644 --- a/src/languages/ru/profanity/huy.json +++ b/src/languages/ru/profanity/huy.json @@ -5,7 +5,7 @@ "id": "ru.obscene.huy.base", "category": "OBSCENE_MAT", "severity": "high", - "source": "ху[йяиёею]", + "source": "(?:хуй|хуя|хуи|хуё|хуе|хую)", "match": { "strict": {}, "loose": { diff --git a/tests/loose-corpus.spec.ts b/tests/loose-corpus.spec.ts index d3a547a..2865c04 100644 --- a/tests/loose-corpus.spec.ts +++ b/tests/loose-corpus.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import { mergeRanges } from "@textfilters/core"; import { createProfanityFilter, filter } from "../src"; @@ -188,4 +189,42 @@ describe("loose corpus", () => { "********", ); }); + + it("keeps Russian obscene root ranges from absorbing a following conjunction", () => { + const input = "привет хуй и мир"; + const ranges = filter.analyze(input).map(([start, end]) => [start, end]); + + expect(ranges).toContainEqual([7, 10]); + expect(ranges).not.toContainEqual([7, 12]); + expect(ranges.every(([, end]) => end <= 10)).toBe(true); + expect(filter.censor(input)).toBe("привет *** и мир"); + }); + + it("keeps Telegram HTML spoiler output limited to the obscene token", () => { + const input = "💬 привет хуй и мир