When enabling a node access module the system will prompt the user to rebuild the permissions.

The url to the rebuild has not being escaped properly.

Comments

gordon’s picture

Issue summary: View changes
StatusFileSize
new13.9 KB
new837 bytes

Patch attached to correct the escaping to show the url correctly.

gordon’s picture

Assigned: Unassigned » gordon
Status: Active » Needs review
realityloop’s picture

Status: Needs review » Reviewed & tested by the community

Simple 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.

webchick’s picture

Assigned: gordon » joelpittet

Hm. 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.

effulgentsia’s picture

+1 to the patch.

it's confusing that ! and @ are doing exactly the opposite of what they're supposed to be doing here

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.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This 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!

  • alexpott committed cc07fe4 on 8.0.x
    Issue #2447831 by gordon: "The content access permissions need to be...
joelpittet’s picture

@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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joelpittet’s picture

Assigned: joelpittet » Unassigned