mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-24 10:48:17 +00:00
Merge "Properly detect unclosed comments"
This commit is contained in:
commit
c10f61f623
|
@ -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",
|
||||
|
|
|
@ -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}}",
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue