Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
workbench_moderation_workbench_block() generates invalid HTML. All message values are put inside em elements, including the moderation form. The moderation form is block-level and cannot go inside the inline-level em element. Fix attached.
Comments
Comment #1
Pls CreditAttribution: Pls commentedPatch works great and fixes the problem for markup.
Comment #2
hass CreditAttribution: hass commentedWhat are you trying to do here? I do not understand the substr logic. Do you like to use strip_tags() for the message?
Comment #3
Liam MorlandThe call to substr() is just a quick way to determine if the "message" actually a moderation form which shouldn't be wrapped in an em element.
Comment #4
hass CreditAttribution: hass commentedLooks not reliable...
Comment #5
Liam MorlandHow about:
Comment #6
stevectorThanks for identifying this!
The invalid HTML is definitely a problem and if a patch like this is the best way to fix it then we'll go with it. I'm posting a revised patch here. It checks for '
I'm open to any opinions on which is more appropriate.
Check_plain() is not an option because that would wreck the form's markup.
Comment #7
Liam MorlandYes, that would work too.
Here is a more robust approach.
Comment #8
stevectorLiam, I'm not following that last patch.
I also now see that my last comment had invalid html in it and was thus cut off!
I tried to say
Comment #9
Liam Morlandcheck_plain() is just used to check if the message is plain text or HTML. If it is HTML, it goes through as-is. If it is plain text, it gets wrapped in an em element.
My last patch uses CSS instead of wrapping messages in an em element. It looks the same, but has slightly different semantics.
Your patch in #6 would work for the form. If a message had any other block-level HTML, it wouldn't work. The check_plain() or CSS approaches would work for any content.
Comment #10
hass CreditAttribution: hass commentedAhhh, NO! All tags are converted to safe HTML. This means
<
become<
and so on. If a%placeholder
insidet()
is used it get's surrounded by<em>
(format_string).Comment #11
Dave ReidRelated, I'm not sure why this code is continuing to use t() since there's no real words in this text. I think this should just be calling drupal_placeholder() manually?
Comment #12
Liam MorlandYes, but the output of check_plain() is not put into the page. The only thing that is done with it is it the compared to the original string. If $message and check_plain($message) are the same, then it is safe to wrap it in an em element.
Yes, it is the message and the label that needs to be translated. Thanks for noticing that.
Comment #13
Liam MorlandHere is an updated patch that removes the call to t() which doesn't do anything anyway because there is no text in that string. (If text is not being translated, that is a different issue and removing t() does not have any effect on that.)
Comment #14
hass CreditAttribution: hass commentedI cannot speak 100% for arabic/hebrew/chinese/japanese, but it's possible that we need to keep this wrapped in t().
Comment #15
Liam MorlandCould be. In that case, use the patch in #7. The only difference is the wrapping in t().
Comment #16
Liam MorlandReroll.
Comment #17
Liam MorlandSorry, this is the reroll.
Comment #19
Liam MorlandThe patch in #17 is fine; the error is about the patch in #16.
Comment #20
Liam MorlandRe-roll. This also applies to 7.x-3.x.
Comment #21
Liam MorlandRe-roll.
Comment #22
Liam Morland