
SafeMarkup::format()
should require arguments without them it is just SafeMarkup::set()
in disguise. #2280965: [meta] Remove every SafeMarkup::set() call documents why this is such a bad idea.
Comment | File | Size | Author |
---|---|---|---|
#28 | 2547851-2.28.patch | 7.79 KB | alexpott |
#28 | 24-28-interdiff.txt | 5.49 KB | alexpott |
#24 | 2547851-2.24.patch | 2.3 KB | alexpott |
#23 | safemarkup_format-2547851-23.patch | 5.41 KB | joelpittet |
#23 | interdiff.txt | 904 bytes | joelpittet |
Comments
Comment #2
alexpottLet's see if this breaks any tests.
Comment #3
alexpottFixing the filter tips page.
Comment #6
alexpottSo this is the SafeMarkup::set() side effect problem in a nutshell. We're not escaping the markup in between the code tags as we should because it is marked safe when it should not be.
Comment #7
dawehnerYou can remove the use statement now, yeah!
Yeah this call was effectively a SafemMarkup::set() call, right? On the other hand #markup will be ran through Xss::filterAdmin() which supports a supersets of these tags:
';
+ $ampersand_as_code = '
' . htmlspecialchars($ampersand, ENT_QUOTES, 'UTF-8') . '
';Doesn't that result into double escaping now? It is just a test, but still ...
Comment #8
alexpottComment #9
alexpottIn fact we can get to the point where FilterHtml is no longer marking any of the help text safe which has got to be saner!
Comment #10
alexpottWrong patch in #9. Here's the correct patch.
Comment #11
dawehnerShould it be explained why? ... because you want to see the tag for itself?
Comment #12
xjmComment #13
alexpottCreated https://www.drupal.org/node/2549107
Comment #14
alexpottImproved documentation.
Comment #15
joelpittetThis looks great and is hilarious that this was done so many times!
There are a few things in the patch that seem a bit out of the scope of the issue.
Not format, shouldn't be part of this patch.
', array('@var' => $tips[$tag][1])), 'class' => array('type')),
...
+ array('data' => ['#prefix' => '
', '#markup' => htmlspecialchars($tips[$tag][1], ENT_QUOTES, 'UTF-8'), '#suffix' => '
'], 'class' => array('type')),This one has arguments, doesn't count.
implicit admin xss filter?
', array('@var' => $entity[1])), 'class' => array('type')),
...
+ array('data' => ['#prefix' => '
', '#markup' => htmlspecialchars($entity[1], ENT_QUOTES, 'UTF-8'), '#suffix' => '
'], 'class' => array('type')),Same has arguments, out of scope.
These could get a nice comma at the end.
This is out of scope, not SafeMarkup::format()
';
- $ampersand_as_code = '
' . $ampersand . '
';+ $link_as_code = '
' . htmlspecialchars($link, ENT_QUOTES, 'UTF-8') . '
';+ $ampersand_as_code = '
' . htmlspecialchars($ampersand, ENT_QUOTES, 'UTF-8') . '
';SafeMarkup::checkPlain? till that other issue gets in.
Comment #16
alexpottUse SafeMarkup::checkPlain when the string does not need to be added to the safe list is bug. Postponing on #2504529: SafeMarkup does not escape some filter tips - remove SafeMarkup usage from FilterHtml which will handle FilterHtml and then this will be a three line or so patch.
Comment #17
joelpittetThis doesn't need to be postponed on that, they are not related to the title of this.
Comment #18
joelpittetThis is a really good self contained fix that should just get in.
Comment #20
joelpittetNot sure how this passed before really but code values need to be escaped. And now with this change it's probably does need to be postponed.
Comment #21
joelpittetPostponing on #2550945: Add Html::escape()
Comment #22
joelpittetUnpostponing this will likely conflict with #2504529: SafeMarkup does not escape some filter tips - remove SafeMarkup usage from FilterHtml
Comment #23
joelpittetBetter escaping testing with
assertEscaped()
Comment #24
alexpottRerolled on top of #2504529: SafeMarkup does not escape some filter tips - remove SafeMarkup usage from FilterHtml.
Comment #25
joelpittetRTBC from me, just need to find someone to second it.
Comment #26
stefan.r CreditAttribution: stefan.r commentedSeconding, this seems like a good idea!
The method documentation still looks good and grepping the code for any
SafeMarkup::set()
without test coverage and a second argument I found nothing.Maybe this could use an
assert('$args !== array()')
if we wanted to also disallowSafeMarkup::checkPlain($string, array());
?Comment #27
dawehnerI'm wondering whether there could be generic code which does not know its placeholders, so it maybe an empty array. For them the assert() would make it a bit harder.
Comment #28
alexpottWe can add the assert later... but lets also fix
format_string()
to work the same way.Comment #29
stefan.r CreditAttribution: stefan.r commentedLooks like we have all the
format_string()
calls here, so RTBCComment #30
webchickCommitted and pushed to 8.0.x. Thanks!
Comment #33
stefan.r CreditAttribution: stefan.r commentedSo contrib is now doing lovely things like this to work around the SafeMarkup::set removal
https://www.drupal.org/node/2563017
Comment #34
joelpittetWow, dx be darned.
They haven't used SafeString:create() yet. At least that would only open up xss for their module instead of on the Safemakup sting list and all the site