Last modified: 2014-11-12 17:28:52 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 50107 - Variable added_lines is now an array instead of a string
Variable added_lines is now an array instead of a string
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
AbuseFilter (Other open bugs)
unspecified
All All
: Normal major (vote)
: ---
Assigned To: Nobody - You can work on this!
https://pt.wikibooks.org/w/index.php?...
: code-update-regression
Depends on:
Blocks: documentation
  Show dependency treegraph
 
Reported: 2013-06-24 15:40 UTC by Helder
Modified: 2014-11-12 17:28 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Helder 2013-06-24 15:40:23 UTC
1. Create a page with "{{this is}}"
2. Edit the page and replace its content by "*THIS IS A BUG ON ABUSE FILTER!":
https://pt.wikibooks.org/wiki/Project:Caixa_de_areia?diff=258499
3. Open [[Special:AbuseFilter/test]], which in my case was
https://pt.wikibooks.org/wiki/Special:AbuseFilter/test?uselang=en
4. Type
------------------------------------------------------------------------
length(added_lines) <= 2 & contains_any( added_lines, "THIS IS A BUG" )
------------------------------------------------------------------------
5. Click "Test" and bang! The edit is detected! If it is of any help, here is the link provided to "examine" the edit:
https://pt.wikibooks.org/w/index.php?title=Especial:Filtro_de_abusos/examine/262161&testfilter=length%28added_lines%29+%3D%3D+1+%26+contains_any%28+added_lines%2C+"THIS+IS+A+BUG"+%29%0A&uselang=en

The filter shouldn't detect it, because "added_lines" obviously has a lot more than 2 characters. Nonetheless, if I replace "<= 2" by "== 1" it is still detected.

How can a string of 31 characters have length 1? This is plain wrong...
Comment 1 Helder 2013-06-25 13:07:12 UTC
Ok, so I made one more test at
https://pt.wikibooks.org/w/index.php?title=Wikilivros%3ACaixa_de_areia&diff=258547&oldid=258546
and used Special:AbuseFilter/test to check the following filter:
------------------------------------------------------------------------
length(added_lines) == 3 & contains_any( added_lines, "Lorem" )
------------------------------------------------------------------------
and the edit was detected.

It seems abuse filter's "added_lines" is an array and then "length(added_lines)" is the number of items on this array.

Such a behavior is not documented at
https://www.mediawiki.org/wiki/Extension:AbuseFilter/Rules_format
and it is not obvious from
https://pt.wikibooks.org/w/index.php?title=Especial:Filtro_de_abusos/examine/262215&testfilter=length%28added_lines%29+%3D%3D+3+%26+contains_any%28+added_lines%2C+%22Lorem%22+%29%0A

that the value of "added_lines" is an array (not an string).
Comment 2 Helder 2013-07-03 15:17:39 UTC
A similar problem happens when I use "user_groups":
For a user , 

The test
--------------------------
"confirmed" in user_groups
--------------------------
matches a user which is in the group "autoconfirmed" but **not** in the group "confirmed". But the documentation[1] says "in" applies only to "strings", so why when I execute
--------------------------
length(user_groups)=4
--------------------------
I also get a match? (the user in question is in exactly 4 groups)

If "user_groups" is a string, its length should be at least the length of "confirmed" (which is 9), not 4.

[1] http://www.mediawiki.org/wiki/Extension:AbuseFilter/Rules_format#Keywords
Comment 3 Helder 2013-07-05 16:21:30 UTC
Here is another test which returns 1 (which means "true"):

(list:= ["a", "b", "c"];) & contains_any(list,"a\n")

I think the real bug is we have no documentation about these variables being arrays and how they are converted to strings (notice the "\n" in the above example).
Comment 5 Helder 2013-07-14 19:51:36 UTC
According to 
https://ru.wikipedia.org/wiki/Special:AbuseFilter/history/99/diff/prev/2152
the
the variable "added_lines" was changed to an array somewhere from 13 February 2013 and as such "length (added_lines)" now gets the number of rows, and this changed the conditions under which existing filters were triggered.
Comment 6 Helder 2013-07-14 20:07:22 UTC
Is this working like this since 2009??? I found the following on r49221:
---------------------------------------------------------------------------
* Use lists instead of implode()d strings in built-in variables wherever it's possible

ATTENTION! This may break filters that rely on "added_lines contains 'bla-bla'" syntax. They'll need to be replaced with "string(added_lines) contains 'bla-bla'"
---------------------------------------------------------------------------
Comment 7 Andre Klapper 2013-07-15 10:50:28 UTC
No need for "[regression]" in subject if you also set the keyword.
However, not sure if I would call it a regression if it's been like this for four years.
Comment 8 Helder 2013-07-15 17:48:14 UTC
Another example of the confusion caused by this (from 17 June 2009):
* [[Special:AbuseFilter/history/172/diff/prev/2121]]
* [[Wikipedia talk:Edit filter/Archive 3#Filter stopped working - strange testing results ..]]
Comment 9 Jesús Martínez Novo (Ciencia Al Poder) 2013-08-16 13:12:34 UTC
See also:
https://www.mediawiki.org/wiki/Extension:AbuseFilter/Rules_format#Conditions

(added and documented by Helder)
Comment 10 Jesús Martínez Novo (Ciencia Al Poder) 2013-08-16 13:13:13 UTC
(In reply to comment #9)
> See also:
> https://www.mediawiki.org/wiki/Extension:AbuseFilter/Rules_format#Conditions
> 
> (added and documented by Helder)

Whoops, ignore that, wrong bug!

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links