Problem/Motivation
All text that appears in a batch progress label is HTML escaped.
If Javascript is enabled, some HTML replacement happens (replacing the escaped HTML by unescaped HTML) so this is only a flash of about half a second. With JS disabled it happens in all steps.
For example, during the install step, the following text appears:
Initializing.<br>

Or during a test (JS disabled):

Proposed resolution
Output as #markup
Remaining tasks
Review patch.
User interface changes
No more double escaped markup showing up on install page or any batch pages.
API changes
None.
Data model changes
None.
Beta phase evaluation
| Issue category | Bug |
|---|---|
| Issue priority | Major because affects installer which is the first thing people see, also this is child issue of #2297711: Fix HTML escaping due to Twig autoescape |
| Unfrozen changes | Unfrozen because it only changes markup |
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | batch.png | 114.18 KB | stefan.r |
| #18 | javascript off.png | 57.68 KB | stefan.r |
| #17 | 2548147-17.patch | 3.79 KB | stefan.r |
| #17 | interdiff-16-17.txt | 361 bytes | stefan.r |
| #16 | 2548147-16.patch | 3.79 KB | stefan.r |
Comments
Comment #2
rainbowarrayMarking this as major which is maybe debatable, but this is one of the first things somebody sees when installing Drupal. It looks awful.
Comment #3
stefan.r commentedWe probably shouldn't be autoescaping the HTML in the init message (the render array is in _batch_progress_page()):
Comment #4
stefan.r commentedI can't reproduce this, the init message is unescaped for me on HEAD
Comment #5
rainbowarrayIt's strange. It flashes unescaped but then switches to escaped during the install process. That makes me wonder if there's some sort of JS replacement going on.
Comment #6
stefan.r commentedI did manage to reproduce this in the end. There is actually some JS replacement in progress.js, where it does
$('div.progress__description', this.element).html(message);. So it really is just a flash.Here's an attempt at a patch...
Comment #7
rainbowarrayI did not see the flash of special characters when I just tried an install with this patch. Nice work.
Comment #8
lauriiiNice to see it becoming a render array. Just curious, why do we need the $message to be escaped with Xss::filter? Isn't that the default behaviour of '#markup'?
Comment #9
stefan.r commentedHmm you're right. #markup does admin XSS escaping which may be enough here assuming it's only admin users who ever see a progress bar. So maybe this could be a 1 line fix.
Comment #10
stefan.r commentedComment #11
stefan.r commentedComment #12
joelpittetThis could use some tests if possible but I think you can fairly assume that the message wouldn't need markup beyond what Xss admin filtering allows.
Comment #13
stefan.r commentedAdded a test
Comment #14
stefan.r commentedComment #15
stefan.r commentedComment #16
stefan.r commentedComment #17
stefan.r commentedreverting a change from that last patch
Comment #18
stefan.r commentedAnd if you disable javascript it's not just on the initial step, but everywhere:
Comment #19
stefan.r commentedComment #20
stefan.r commentedComment #21
stefan.r commentedComment #22
idebr commentedI reported this earlier in #2443005: Html displayed as text in installer initial batch operations message
Comment #23
Aki Tendo commentedLooks good to me.
Comment #24
stefan.r commentedComment #25
lauriiiRTBC++
Comment #26
catchThe error handling also uses a
<br />tag in two different places - do you know whether this is also double escaped?Also wondering whether there's something simple we can do to just ditch the hardcoded
<br />altogether.Comment #27
stefan.r commentedWe should ditch most
<br />tags but for this one I'm not sure how or what it's purpose is. Some CSS trickery on the.progress__descriptionmay be possible, but IMO it's out of scope here as it's much less of an issue than the HTML escaping, where all labels are affected (not just the <br />thing), and many of them have markup which also gets escaped (ie. #18).As to the
<br />from the batch error handler, I tested and it's not double escaped:The linebreak there is easier to get rid of, we can just wrap each error message in a block-level element instead.
The other bit is JS so unrelated.
Comment #28
stefan.r commentedClarifying in the IS that this does not just affect the installer.
Comment #29
catchMakes sense. Opened #2555567: Remove hard-coded <br /> from batch API in case anyone wants to look at the break tags.
Committed/pushed to 8.0.x, thanks!