Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
node system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2015 at 04:20 UTC
Updated:
24 Sep 2016 at 18:03 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
gordon commentedPatch attached to correct the escaping to show the url correctly.
Comment #2
gordon commentedComment #3
realityloop commentedSimple 2 char change, correct the escaping.. passes tests and includes screenshots, thanks @gordon
Refer to https://www.drupal.org/node/322774 that shows this is a good way to do this.
Comment #4
webchickHm. While that's certainly what the docs say to do, it's confusing that ! and @ are doing exactly the opposite of what they're supposed to be doing here.
Assigning to joelpittet to give a sanity check.
Comment #5
effulgentsia commented+1 to the patch.
The way to make sense of that is that the ! or @ prefix defines the escaping behavior of the token, not of the entire output string. In this case, the token is just the URL (just the value of the
href), but the bug being fixed is the escaping behavior of the entire<a>tag (i.e., the part outside the token). So what's happening is that by using@, you're saying, "go ahead and sanitize the URL for HTML output", which then lets t() mark the entire string as safe for HTML output. OTOH, when you use!, you're saying, "don't sanitize this for HTML output" (there are several reasons you might want to do this, depending on what you're then planning on doing with that string, see docs of String::format() for details), which is fine, but then if the resulting output is printed in Twig, then it gets autoescaped, which is what you don't want for the case being fixed by this issue. See https://www.drupal.org/node/2445441 for the related change record about this.Comment #6
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed cc07fe4 and pushed to 8.0.x. Thanks!
Comment #8
joelpittet@webchick Well that is correct as it stands:) I am convinced that
@is correct here and it's the way we should do it in core BUT, big BUT I'm not convinced that!should be escaped. It's an explicit developer of something to be raw data... though SafeMarkup::set()ing doesn't sit well but better than what it is now, IMO.Comment #10
joelpittet