Page MenuHomePhabricator

Function applyDiffStyle uses regexes which do not detect CSS classes appropriately
Open, NormalPublic

Description

Working on this task requires knowledge of regular expressions in PHP.

Currently, the applyDiffStyle() function uses the regex
/(<[^>]+)class=(['\"])$class\\2([^>]*>)/
to try to detect the CSS classes.
This only works if the element has only one class and fails for some classes (mentioned on T36800) which appear at
https://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=rss&action=purge
E.g.:

Something like
(<[^>]+)class=(['\"])$class(| .+?)\\2([^>]*>)
would be slightly better:
http://www.rubular.com/r/BGlcrGfRtd
but still wouldn't work in case there is some class before the specified class:
http://www.rubular.com/r/xLWx9MWBSL

Besides, notice that
\"
has only one backslash and
\\2
has two. I don't know what is the proper syntax for this in PHP strings but it is likely that one of the two needs to be fixed.

A patch exists in Wikimedia Gerrit which needs to be reworked.

See also:


Version: 1.19
Severity: normal

Details

Reference
bz34801

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 12:11 AM
bzimport set Reference to bz34801.
bzimport added a subscriber: Unknown Object (MLST).
He7d3r created this task.Feb 29 2012, 5:50 PM

not happening for 1.20 tarball.

Pratikbsp added a subscriber: Pratikbsp.EditedJan 26 2015, 7:33 PM

I am new to mediawiki and foss.I would like to work on this bug as my first fix

Rits added a subscriber: Rits.Feb 25 2015, 7:23 PM
Rits added a comment.Feb 25 2015, 7:27 PM

i have found the solution, i am submitting a patch to review

Rits added a comment.Feb 26 2015, 10:56 AM

http://www.rubular.com/r/tTdxPEE4QO
can someone review if it is the right solution

Change 193081 had a related patch set uploaded (by Rits):
T36801 Changed Function applyDiffStyle uses regexes which do not detect CSS classes appropriately

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

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptAug 12 2016, 4:54 PM

Change 193081 abandoned by TTO:
T36801 Changed Function applyDiffStyle uses regexes which do not detect CSS classes appropriately

Reason:
No progress in 2 years.

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

Framawiki moved this task from Backlog to Doing on the good first bug board.Dec 2 2017, 1:36 PM
Restricted Application added a project: Growth-Team. · View Herald TranscriptSep 24 2018, 9:52 AM