There is a bug with lazy loaded references that leads to references not showing up and the drawer being closed.
Steps to reproduce
- Opt into beta
- Visit https://en.m.wikipedia.org/wiki/Barack_Obama
- Search for ""
- Tap ""
The reference drawer is shown and stays open until dismissed manually
Sometimes nothing happens, other times the drawer opens and immediately slams shut!
note: this is happening on stable as well
- Chromium v64.0.3282.167 (Official Build) Built on Ubuntu , running on Ubuntu 17.10 (64-bit)
- Mobile web BETA mode
- Ubuntu v17.10
- Android v8.1.0
- Pixel XL
The bug is inside ReferencesHtmlScraperGateway.getReferenceFromContainer
I started by investigating beta. Inside ReferencesDrawer.showReference
gateway is an instance of ReferencesMobileViewGateway
The call to getReference throws an error
<sup id="cite_ref-Obama_1995,_2004,_pp._9–10_11-0" class="reference"><a href="#cite_note-Obama_1995,_2004,_pp._9%E2%80%9310-11"></a></sup>
<sup id="cite_ref-Obama_1995,_2004,_pp._9–10_11-0" class="reference"><a href="#cite_note-Obama_1995,_2004,_pp._9–10-11"></a></sup>
The problem lies somewhere inside the HTMLFormatter. After 20 mins debugging it seems that the problem relies inside MobileFormatter::filterContent or HtmlFormatter::getDoc
A client side fix can be made but it feels a little hacky. It would look like this:
- If the reference cannot be found, attempt to call decodeURIComponent on the href and try again.
A server side fix will be trickier as it's likely to be related to the loadHTML method of DOMDocument. We do not directly modify the href attributes of the link.