Page MenuHomePhabricator

Search results display css from TemplateStyles tags
Closed, ResolvedPublic

Description

In Swedish Wikipedia css code from TemplateStyles are shown in article extracts in search results in some searches:

For example first item "Alec John Such" in this search shows:

"nested-talk{border:1px solid#c0c090;background-color:#f8eaba;width:100%;margin:2px 4px}Alec John Such, född 14 november 1956 i Yonkers i New York, är en amerikansk musiker"

and third item "John Entwistle" shows:

".mw-parser-output .infobox.geography .maptable th{border:0;padding:0}John Alec Entwistle, född 9 oktober 1944 i Chiswick i västra London, död 27 juni"

Those articles contains templates that get their css from TemplateStyles tags.

Event Timeline

Probably style and link should be added to WikiTextStructure::$excludedElementSelectors?

Deskana subscribed.

This blocks further deployments of TemplateStyles.

link tags aren't needed since they have no content:

>>> $text = 'text ' . Html::inlineStyle( 'stylesheet' ) . ' ' . Html::element( 'link', [ 'rel' => 'mw-deduplicated-inline-style', 'href' => 'mw-data:abcdefg' ] );                                                                             
=> "text <style>stylesheet</style> <link rel="mw-deduplicated-inline-style" href="mw-data:abcdefg"/>"
>>> ( new WikiTextStructure( new ParserOutput( $text ) ) )->getMainText()
=> "text stylesheet"

Change 419259 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] WikiTextStructure: Exclude <style> tags

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

Change 419259 merged by jenkins-bot:
[mediawiki/core@master] WikiTextStructure: Exclude <style> tags

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

From a code perspective this is done now, the fix will be deployed with 1.31.0-wmf.26.

@dcausse, do you want to keep this open to track the reindexing you mentioned, or should we close this task?

@Anomie I think this task can be closed, I have T189694 to track the reindexing.

Anomie claimed this task.