Page MenuHomePhabricator

TemplateStyles CSS appears in Quick facts header
Closed, ResolvedPublic

Description

The TemplateStyles CSS in the header cell of the infobox appears in the header of the infobox (the tappable line, which is shown in collapsed state as well). I think it uses something like $('th').text() to get the text, which includes hidden elements as well. The below example shows hu:Rédics–Zalaegerszeg-vasútvonal; the CSS is added in {{BS-header}}.

App version: 2.7.269-r-2018-12-11
OS version: 6.0.1 (Marshmallow), Samsung

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Dbrant added a subscriber: Dbrant.

This is likely an issue in the content service and/or parsoid, since the issue also appears in the mobile-html endpoint:
https://hu.wikipedia.org/api/rest_v1/page/mobile-html/R%C3%A9dics%E2%80%93Zalaegerszeg-vas%C3%BAtvonal

ssastry added a subscriber: ssastry.

https://hu.wikipedia.org/api/rest_v1/page/html/R%C3%A9dics%E2%80%93Zalaegerszeg-vas%C3%BAtvonal doesn't show this .. so, Parsoid output looks fine. Untagging Parsoid.

wikimedia-page-library/src/transform/CollapseTable.js, line 111 removes some elements, maybe style can be simply added to the list.

Tgr added a subscriber: Tgr.Feb 7 2019, 5:06 AM

The table collapse logic uses textContent is almost always bad, innerText should be used instead, unless the logic is particularly performance-sensitive or the text is guaruanteed to not contain invisible things. innerText will only show visible text while textContent just concatenates the contents of all nodes within, even nodes which do not contain "real" text, like <script> or <style>.

If innerText is not an option (performance or poor support in Domino or maybe the table is collapsed by default so we do need invisible text) then at least <script> and <style> elements should be purged first. (It will still have interesting failure modes though, e.g. some wiki tables use invisible text for manipulating the sort order, some microformats include invisible text...)

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptApr 5 2019, 6:50 AM
MSantos claimed this task.Jun 11 2019, 8:26 PM
MSantos moved this task from To Do to Doing on the Product-Infrastructure-Team-Backlog (Kanban) board.

@Tgr is not possible to use innerText, the tests even fail, this patch [1] is stripping style and script from fragmentHeader instead.

[1] https://github.com/wikimedia/wikimedia-page-library/pull/201

bearND closed this task as Resolved.Tue, Jul 30, 6:38 PM