@@ -378,6 +378,31 @@ describe("sanitize_content.cjs", () => {
378378 const result = sanitizeContent ( '[text](https://github.com "@exploituser inject payload")' ) ;
379379 expect ( result ) . toBe ( "[text (`@exploituser` inject payload)](https://github.com)" ) ;
380380 } ) ;
381+
382+ it ( "should neutralize markdown link titles when allowedAliases is specified (XPIA regression)" , ( ) => {
383+ // Regression: neutralizeMarkdownLinkTitles must run in the allowedAliases branch too.
384+ // Previously the title was passed through unchanged when allowedAliases were provided.
385+ // The title is moved into the visible link text (no longer steganographic), not stripped.
386+ const result = sanitizeContent ( '[Result](https://github.com "XPIA: inject")' , { allowedAliases : [ "author" ] } ) ;
387+ expect ( result ) . toBe ( "[Result (XPIA: inject)](https://github.com)" ) ;
388+ } ) ;
389+
390+ it ( "should strip reference-style link titles when allowedAliases is specified" , ( ) => {
391+ const result = sanitizeContent ( '[x][ref]\n\n[ref]: https://github.com "hidden payload"' , {
392+ allowedAliases : [ "author" ] ,
393+ } ) ;
394+ expect ( result ) . not . toContain ( "hidden payload" ) ;
395+ expect ( result ) . toBe ( "[x][ref]\n\n[ref]: https://github.com" ) ;
396+ } ) ;
397+
398+ it ( "should neutralize link title @mentions via allowedAliases path without exposing the title steganographically" , ( ) => {
399+ // The title @mention must be moved into visible link text and then selectively filtered.
400+ // The allowed alias should remain un-neutralized after being moved to visible text.
401+ const result = sanitizeContent ( '[text](https://github.com "@author inject")' , {
402+ allowedAliases : [ "author" ] ,
403+ } ) ;
404+ expect ( result ) . toBe ( "[text (@author inject)](https://github.com)" ) ;
405+ } ) ;
381406 } ) ;
382407
383408 describe ( "XML/HTML tag conversion" , ( ) => {
0 commit comments