Merge "Properly detect unclosed comments"

This commit is contained in:
jenkins-bot 2018-04-11 00:02:35 +00:00 committed by Gerrit Code Review
commit c10f61f623
4 changed files with 7 additions and 1 deletions

View file

@ -389,6 +389,7 @@
"abusefilter-exception-overridebuiltin": "Illegal overriding of built-in variable \"$2\" at character $1.",
"abusefilter-exception-outofbounds": "Requesting non-existent list item $2 (list size = $3) at character $1.",
"abusefilter-exception-notlist": "Requesting array item of non-array at character $1.",
"abusefilter-exception-unclosedcomment": "Unclosed comment at character $1.",
"abusefilter-action-tag": "Tag",
"abusefilter-action-throttle": "Throttle",
"abusefilter-action-warn": "Warn",

View file

@ -422,6 +422,7 @@
"abusefilter-exception-overridebuiltin": "Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string\n* $2 - Built-in variable",
"abusefilter-exception-outofbounds": "Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string\n* $2 - Index\n* $3 - Number of items in list",
"abusefilter-exception-notlist": "Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string",
"abusefilter-exception-unclosedcomment": "Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string",
"abusefilter-action-tag": "{{doc-abusefilter-action}}\n\nThe edit or change can be 'tagged' with a particular tag, which will be shown on Recent Changes, contributions, logs, new pages, history, and everywhere else. \n\nThis is a verb in the imperative form.\n\n{{Identical|Tag}}",
"abusefilter-action-throttle": "{{doc-abusefilter-action}}",
"abusefilter-action-warn": "{{doc-abusefilter-action}}",

View file

@ -31,7 +31,7 @@ class AFPUserVisibleException extends AFPException {
// abusefilter-exception-dividebyzero, abusefilter-exception-unrecognisedvar
// abusefilter-exception-notenoughargs, abusefilter-exception-regexfailure
// abusefilter-exception-overridebuiltin, abusefilter-exception-outofbounds
// abusefilter-exception-notlist
// abusefilter-exception-notlist, abusefilter-exception-unclosedcomment
return wfMessage(
'abusefilter-exception-' . $this->mExceptionID,
array_merge( [ $this->mPosition ], $this->mParams )

View file

@ -113,6 +113,10 @@ class AbuseFilterTokenizer {
// Read past comments
while ( preg_match( self::COMMENT_START_RE, $code, $matches, 0, $offset ) ) {
if ( strpos( $code, '*/', $offset ) === false ) {
throw new AFPUserVisibleException(
'unclosedcomment', $offset, [] );
}
$offset = strpos( $code, '*/', $offset ) + 2;
}