Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
views.module
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Sep 2015 at 17:44 UTC
Updated:
11 Oct 2015 at 14:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dawehner@catch
Can you specific which one you talk about?
I just see examples of
@urland!urlpretty much. Used"=\"@\""and and=\"!\"Comment #3
catch@dawehner this is not about placeholders, it's about the return value of t() - for example using that in a title or alt attribute.
See #2506479-45: Replace !placeholder with @placeholder for non URLs in t() in Views, except for t() output that is used as an attribute value.
https://www.drupal.org/files/issues/views-placeholder-2506479.45.interdi... is the list of t() calls that eventually end up as the value of an HTML attribute.
Postponing this on #2509218: Ensure that SafeString objects can be used in non-HTML contexts.
Comment #4
lauriiiIS can be worked on before #2509218: Ensure that SafeString objects can be used in non-HTML contexts is in
Comment #5
dawehnerComment #6
alexpottThis issue will need to add and test an HTML to attribute output formatter and test it.
Comment #7
lauriiiWill be working on this
Comment #8
plach@laurii: @alexpott:
Actually @catch suggested in #2509218-142: Ensure that SafeString objects can be used in non-HTML contexts that we don't need and output strategy for HTML attributes, see also the recommended way in the related CR.
Comment #9
catchFor these cases can't we cover to plain text then stick it into Attributes? Reviewing from phone so haven't revisited the Views code.
Comment #10
dawehnerSo
$display_titleisSo the problem is that t('Master') might have bad strings, which then ends up in the attribute. In the meantime I'll write on a test, just to be sure about it.
Comment #11
lauriiiThis creates double autoescape for the Enable view mode button. Reproduce by adding a view mode with html inside display name, then disable view mode.
Comment #12
plachI think it was View display not view mode
Comment #13
dawehnerHere is a test coverage. It just proves that there is no problem yet.
Comment #14
plachHaving a look to this one
Comment #15
plachDiscussed with @alexpott and @dawehner a slightly different way: since attribute values will always be autoescaped by Twig, we just need to convert safe markup to string and we are done.
Comment #16
plachMoar test coverage
Comment #17
plachI updated the CR at https://www.drupal.org/node/2574697 to reflect the new approach taken here.
Comment #18
lauriiiJust curious, why are we testing the safeness here?
Comment #20
plachFailures...
Comment #22
dawehnerWe should better expand the unit tests here
We could just call out to
views_ui_truncate()Comment #25
plachAddressed #22, now working on removing
!support altogether.Comment #26
plach@lauriii:
Because safe strings have already been escaped, instead unsafe strings need regular escaping.
Comment #27
plachJust a small clean-up, removing of ! is being addressed in #2571695: Remove !placeholder and unsafe string return from SafeMarkup::format(). If this is green we should be done here.
Comment #28
plachComment #29
plachUpdated IS
Comment #30
dawehnerThe patch is looking great beside this additional test coverage
Comment #31
pwolanin commentedIs there test coverage for the change in FormBuilder?
Comment #32
plachYes, see the
FormBuilderTesthunk.Comment #33
dawehnerIts green and I consider it as green.
Should the
Attributeclass explicit document this new behaviour? It has quite some documentation already.Comment #34
plachAdded docs. I reviewed the additional test coverage @dawehner provided and this is RTBC on my end.
Comment #35
dawehnerPerfect!
Comment #36
xjmThere are two still
!placeholderin Views with this applied:Should those be addressed here or in a separate issue?
Comment #37
plach@xjm:
I'll remove them in #2571695: Remove !placeholder and unsafe string return from SafeMarkup::format().
Comment #38
plachNope, sorry, one is an attribute.
Comment #39
dawehnerGiven our discussion the second one needs some conversion, the first one is totally fine.
Comment #40
xjmSo we talked about the first hunk there; it's not a placeholder... there are no
$args. It's just actually the string!has.Not sure how a translator would ever translate that into their own language since it just looks like a placeholder. :P But that's not in scope here.
Second hunk though will need to be addressed.
Comment #41
plachFixed #36.
Comment #42
dawehnerso $label is coming from
\Drupal\views\Views::fetchPluginNames, which does the following bits:which will loose safeness
Comment #43
plachAlright
Comment #44
dawehnerThank you!
Comment #45
catchSlightly confused why this breaks. If we don't decode entities for both variables, then we decode entities for both variables, why would the former comparison fail?
I'd been hesitant about adding support for this, but in practice this is really straightforward and we have a great way to distinguish between plain text and HTML via SafeStringInterface. Also it's good that AttributeString still uniformly does Html::escape(). So generally glad we got to this point.
Comment #46
dawehnerDoes that mean we need to check first for safeness on the
$element['#value']before converting it and otherwise use the raw value?Comment #47
plachThe comparison may fail if we provide a safe string as
$element['#value']having HTML markup inside (HTML-escaped during the comparison): the value will be sent as unescaped by the browser. For instance:Comment #48
plachI don't think so, I discussed this with @alexpott: the current approach will work in any scenario (as the tests show).
Comment #49
alexpottIt is not just that browsers submit the unescaped version of the input value is that they basically to a decode entities on the value of a button.

<input type="button" value="Cancel <br>">will make a button that looks like this...Comment #50
alexpottI've tested this on multiple browsers on a Mac:
Chrome Version 45.0.2454.99 (64-bit)
Firefox 40.0.3
Safari Version 8.0.8
Comment #51
catchOK so that really needs an inline comment. A bit of googling did not find any reference to browsers decoding entities like this. Apart from that RTBC for me though.
Comment #53
alexpottThe relevant docs are http://www.w3.org/TR/html401/interact/forms.html#h-17.4 which says that value is
CDATAwhich means :According to http://www.w3.org/TR/html401/types.html#type-cdata
Comment #54
plachImproved docs, thanks for the pointers :)
Comment #55
stefan.r commentedthe first hunk is used in #2571695: Remove !placeholder and unsafe string return from SafeMarkup::format() as well, maybe we just copypaste from what we did there or wait for that to go in first? It also has tests.
Comment #56
catchWon't input already be entity decoded?
Comment #57
plachBetter version + some changes from #2571695: Remove !placeholder and unsafe string return from SafeMarkup::format().
Comment #58
dawehnerThank you @plach
This documentation helps people to understand things and well, it seems to be an outstanding bug since forever in form API. If someone cares about it,
them could create a new isssue for backporting this particular change.
(No smiley here)
Comment #60
catchCommitted/pushed to 8.0.x, thanks!
Comment #61
stefan.r commentedSee #2575789: Decode entities when determining which button was clicked for the D7 backport, it just needs tests