Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
theme system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Jul 2015 at 12:06 UTC
Updated:
3 Sep 2015 at 08:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
olli commentedI think this bug was hidden before #2505989: Controllers render caching at the top level and setting a custom page title lose the title on render cache hits because node title was not cached. On render cache hit we get a title from cache that contains some html tags like
<span data-quickedit-field-id="node/1/title/en/full" class="field field-node--title field-name-title field-type-string field-label-hidden">article&039;s "title"</span>and this string is marked as safe, but later the result of strip_tags() in template_preprocess_html() is not marked as safe.Comment #2
olli commentedThis also affects
<title>on node edit page.Comment #3
borisson_I can't reproduce this issue on current HEAD.Looks like I can, let's see if the patch solves the issue.Comment #4
borisson_I can reproduce the issue and the patch solves the issue.
Comment #5
alexpottThis needs tests.
Comment #6
olli commentedWould
SafeString::create(trim(strip_tags($variables['page']['#title'])))work better in case some other code marks an identical string (to the resulting 'title' here) as safe?Comment #7
olli commented#6 .. and do we still need ensure special characters are escaped with
htmlspecialchars(Html::decodeEntities(..?Comment #8
borisson_test-only should fail, that also acts as an interdiff.
Comment #9
dawehnerWait, so why is $variables['page']['#title'] escaped already? We should at least explain it, but this feels like the wrong fix to be honest. We should escape just when we output and this is it
Comment #11
borisson_The previous patch did feel like a wrong approach, attached patch is also the wrong approach I think but it works just as well.
Comment #13
borisson_The code in #2549393: Remove SafeMarkup::escape() and rely more on Twig autoescaping makes this issue pass, including the newly added test.
I attached a patch with #2549393: Remove SafeMarkup::escape() and rely more on Twig autoescaping and the test created in #8 (that should pass) and a patch with just the test (that should fail)
I think we could move the new testcoverage added here to #2549393: Remove SafeMarkup::escape() and rely more on Twig autoescaping and resolve this issue or keep this one as a followup to #2549393: Remove SafeMarkup::escape() and rely more on Twig autoescaping.
Comment #14
catchComment #16
olli commented#9
I think it is not already escaped but gets autoescaped (except on render cache miss it is marked safe).
Can we use decodeEntities and autoescaping here or should we use SafeString like #6?
Comment #17
olli commented#16.1 doesn't make much sense.. I think we get the title from these:
EntityViewController::buildTitle()
NodeForm::form()
Comment #18
wim leersComment #19
olli commentedThis also affects _title_callback like BlockContentController::getAddFormTitle():
Special characters in the label of block content type get double escaped.
Comment #20
ianthomas_ukThis can probably be marked as a duplicate of #2560641: Remove all usages SafeMarkup::checkPlain() from render arrays
Comment #23
alexpottSo once #2560641: Remove all usages SafeMarkup::checkPlain() from render arrays lands - does the test only patch pass?
Comment #24
lauriiiLets see :P
Comment #26
alexpottThis test is now included as a part of #2560641-25: Remove all usages SafeMarkup::checkPlain() from render arrays - @borisson_ and @olli can you comment on that issue so you can get credit - thanks!