Working on this task requires knowledge of regular expressions in PHP.
Currently, [[ https://phabricator.wikimedia.org/diffusion/MW/browse/master/includes/FeedUtils.php;5b0c72bca5381a50429ae5ef0d876eb5c71ab741$259 | the applyDiffStyle() function ]] uses the [[ https://en.wikipedia.org/wiki/Regular_expression | 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.:
* diff: http://www.rubular.com/r/Q6x0qNBRmo
* diffchange: http://www.rubular.com/r/0ToRFfpvXA
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 [[ https://www.mediawiki.org/wiki/Gerrit/Tutorial#Amending_a_change_.28your_own_or_someone_else.27s.29 | needs to be reworked ]].
See also:
* {T36800}
* {T36798}
--------------------------
**Version**: 1.19
**Severity**: normal