diff --git a/includes/Hooks.php b/includes/Hooks.php index e48dd4c8..e66150b3 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -223,7 +223,7 @@ class Hooks implements $parserError = htmlspecialchars( $e->getMessage() ); // #iferror-compatible error element - return "" . + return "" . $parserError . ""; } } diff --git a/modules/ext.scribunto.errors.js b/modules/ext.scribunto.errors.js index 7330ac3e..12a9bcc3 100644 --- a/modules/ext.scribunto.errors.js +++ b/modules/ext.scribunto.errors.js @@ -1,11 +1,15 @@ ( () => { mw.hook( 'wikipage.content' ).add( () => { - const regex = /^mw-scribunto-error-(\w+)/; + const regex = /\bmw-scribunto-error-(\w+)\b/; let popup; $( '.scribunto-error' ).each( ( index, span ) => { - const matches = regex.exec( span.id ); + let matches = regex.exec( span.className ); + if ( matches === null ) { + // T375539: backward-compatibility with old cached HTML + matches = regex.exec( span.id ); + } if ( matches === null ) { mw.log( 'mw.scribunto.errors: regex mismatch!' ); return; diff --git a/tests/parser/luaParserTests.txt b/tests/parser/luaParserTests.txt index 108fec31..20c6916c 100644 --- a/tests/parser/luaParserTests.txt +++ b/tests/parser/luaParserTests.txt @@ -272,10 +272,10 @@ extension=ScribuntoErrors-5e10d413 cat=Pages_with_script_errors sort= extension[ScribuntoErrors-5e10d413]="

Script error: No such module \"foo\".

No further details are available.

" !! html/php -

Script error: No such module "foo". +

Script error: No such module "foo".

!! html/parsoid -

Script error: No such module "foo".

+

Script error: No such module "foo".

!! end !! test @@ -290,10 +290,10 @@ extension=ScribuntoErrors-d64a22ba cat=Pages_with_script_errors sort= extension[ScribuntoErrors-d64a22ba]="

Script error: The function \"blah\" does not exist.

No further details are available.

" !! html/php -

Script error: The function "blah" does not exist. +

Script error: The function "blah" does not exist.

!! html/parsoid -

Script error: The function "blah" does not exist.

+

Script error: The function "blah" does not exist.

!! end !! test