Page MenuHomePhabricator

AbuseFilter: API is responding with wikitext instead of HTML in the "warning" property
Closed, ResolvedPublic

Description

Screenshot of problem in local VisualEditor dev

The code [1] is using $status->getHtml() but apparently it doesn't work as expected because I'm getting raw wikitext.

"edit": {
    "code": "abusefilter-warning",
    "info": "Hit AbuseFilter: Blanking articles",
    "warning": "'''Warning:''' This action has been automatically identified as harmful.\nUnconstructive edits will be quickly reverted,\nand egregious or repeated unconstructive editing will result in your account or IP address being blocked.\nIf you believe this action to be constructive, you may submit it again to confirm it.\nA brief description of the abuse rule which your action matched is: Blanking articles",
    "result": "Failure"
}

To import the filter, use "Special:AbuseFilter/import" on your localwiki with:

{"row":{"af_id":"1","af_pattern":"!\"autoconfirmed\" in user_groups\r\n& new_size < 50\r\n& old_size > 500\r\n& article_namespace == 0","af_user":"1","af_user_text":"Root","af_timestamp":"20130715214820","af_enabled":"1","af_comments":"","af_public_comments":"Blanking articles","af_hidden":"0","af_hit_count":"9","af_throttled":"1","af_deleted":"0","af_actions":"warn,disallow,tag","af_global":"0","af_group":"default"},"actions":{"disallow":{"action":"disallow","parameters":[""]},"tag":{"action":"tag","parameters":["blanking"]},"warn":{"action":"warn","parameters":["abusefilter-warning"]}}}

[1] https://github.com/wikimedia/mediawiki-extensions-AbuseFilter/blob/a6b1dade840841ff7adf2ff289b6428f930d6796/AbuseFilter.hooks.php#L22-L57


Version: unspecified
Severity: normal

Attached:

Details

Reference
bz51403

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:59 AM
bzimport added a project: AbuseFilter.
bzimport set Reference to bz51403.
bzimport added a subscriber: Unknown Object (MLST).
Krinkle created this task.Jul 15 2013, 10:17 PM
hoo added a comment.Jul 15 2013, 10:42 PM

That's because Status::getHTML isn't actually doing real parsing... going to look at this tomorrow

kwwilliams wrote:

I don't think this is really what people want to be doing (regardless of whether HTML is being presented by this call or not). Take a look at filter 554 on English Wikipedia (http://en.wikipedia.org/wiki/Special:AbuseFilter/554). Note how it triggers a message of abusefilter-top100. That causes the standard wikitext editor to display http://en.wikipedia.org/w/index.php?title=MediaWiki:abusefilter-top100 which explains what's wrong with the edit. That's what you need to display, not the short description (in this case "top100 blog charts", which doesn't mean squat to a new editor).

Change 73895 had a related patch set uploaded by Hoo man:
Really parse the API warning in the APIEditBeforeSave hook

https://gerrit.wikimedia.org/r/73895

hoo added a comment.Jul 15 2013, 11:23 PM

(In reply to comment #2)

I don't think this is really what people want to be doing (regardless of
whether HTML is being presented by this call or not). Take a look at filter
554
on English Wikipedia (http://en.wikipedia.org/wiki/Special:AbuseFilter/554).
Note how it triggers a message of abusefilter-top100. That causes the
standard
wikitext editor to display
http://en.wikipedia.org/w/index.php?title=MediaWiki:abusefilter-top100 which
explains what's wrong with the edit. That's what you need to display, not the
short description (in this case "top100 blog charts", which doesn't mean
squat
to a new editor).

That's exactly what we're trying to do.

hoo added a comment.Jul 15 2013, 11:25 PM

(Sorry, if my last comment was unlcear:) Showing the full warning message, I mean.

Change 73895 merged by jenkins-bot:
Really parse the API warning in the APIEditBeforeSave hook

https://gerrit.wikimedia.org/r/73895

We will deploy this fix today.