@@ -1488,6 +1488,57 @@ describe("sanitize_content.cjs", () => {
14881488 const expected = "" ;
14891489 expect ( sanitizeContent ( input ) ) . toBe ( expected ) ;
14901490 } ) ;
1491+
1492+ it ( "should remove left-to-right mark (U+200E)" , ( ) => {
1493+ const input = "Hello\u200EWorld" ;
1494+ const expected = "HelloWorld" ;
1495+ expect ( sanitizeContent ( input ) ) . toBe ( expected ) ;
1496+ } ) ;
1497+
1498+ it ( "should remove right-to-left mark (U+200F)" , ( ) => {
1499+ const input = "Hello\u200FWorld" ;
1500+ const expected = "HelloWorld" ;
1501+ expect ( sanitizeContent ( input ) ) . toBe ( expected ) ;
1502+ } ) ;
1503+
1504+ it ( "should remove soft hyphen (U+00AD)" , ( ) => {
1505+ const input = "Hello\u00ADWorld" ;
1506+ const expected = "HelloWorld" ;
1507+ expect ( sanitizeContent ( input ) ) . toBe ( expected ) ;
1508+ } ) ;
1509+
1510+ it ( "should remove combining grapheme joiner (U+034F)" , ( ) => {
1511+ const input = "Hello\u034FWorld" ;
1512+ const expected = "HelloWorld" ;
1513+ expect ( sanitizeContent ( input ) ) . toBe ( expected ) ;
1514+ } ) ;
1515+ } ) ;
1516+
1517+ describe ( "@mention bypass prevention via invisible characters" , ( ) => {
1518+ it ( "should neutralize @mention with U+200F (RTL mark) inserted between @ and username" , ( ) => {
1519+ const input = "@\u200Fadmin please review" ;
1520+ expect ( sanitizeContent ( input ) ) . toBe ( "`@admin` please review" ) ;
1521+ } ) ;
1522+
1523+ it ( "should neutralize @mention with U+200E (LTR mark) inserted between @ and username" , ( ) => {
1524+ const input = "@\u200Eadmin please review" ;
1525+ expect ( sanitizeContent ( input ) ) . toBe ( "`@admin` please review" ) ;
1526+ } ) ;
1527+
1528+ it ( "should neutralize @mention with U+00AD (soft hyphen) inserted between @ and username" , ( ) => {
1529+ const input = "@\u00ADadmin please review" ;
1530+ expect ( sanitizeContent ( input ) ) . toBe ( "`@admin` please review" ) ;
1531+ } ) ;
1532+
1533+ it ( "should neutralize @mention with U+034F (combining grapheme joiner) inserted between @ and username" , ( ) => {
1534+ const input = "@\u034Fadmin please review" ;
1535+ expect ( sanitizeContent ( input ) ) . toBe ( "`@admin` please review" ) ;
1536+ } ) ;
1537+
1538+ it ( "should neutralize @mention with multiple invisible chars inserted between @ and username" , ( ) => {
1539+ const input = "ping @\u200E\u200F\u00AD\u034Fadmin now" ;
1540+ expect ( sanitizeContent ( input ) ) . toBe ( "ping `@admin` now" ) ;
1541+ } ) ;
14911542 } ) ;
14921543
14931544 describe ( "Unicode normalization (NFC)" , ( ) => {
0 commit comments