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.
When translating the strings from the confirmation message (node/[nid]/webform/configure), including the html-tags (such as <p>
and <strong>
), these html-tags are being displayed as plain text.
Original confirmation message:
Thank you for your message.
We'll get in touch a.s.a.p.
Translated message:
<p><strong>
Merci pour votre message</strong></p>
<p>
Nous vous contacterons dès que possible</p>
Is there a setting that I'm overlooking?
Comments
Comment #1
knalstaaf CreditAttribution: knalstaaf commentedTried to work around this by disabling the wysiwyg editor (CKeditor), but then I'm getting this:
There seems to be no way to get around this…
Comment #2
Stevel CreditAttribution: Stevel commentedIs ckeditor active when you enter the translation? What happens when you disable ckeditor and replace the < and > with < and > resp.?
Comment #3
knalstaaf CreditAttribution: knalstaaf commentedI switched to an input format without CKeditor (manual input of HTML), but then I get the result as mentioned in #1.
Comment #4
joel_osc CreditAttribution: joel_osc at OpenPlus commentedI can recreate this issue and can reproduce it in devel/php with the following lines of code:
If you change the 'langcode' => 'fr' to 'en' then the html tags are shown correctly. I think we need to look a bit further into i18n_string to see what is going on.
Comment #5
joel_osc CreditAttribution: joel_osc at OpenPlus commentedI think this is a reasonable fix, it would be good to get some community input on it before I produce a patch. It is a one line fix in webform_localization.i18n.inc which sets 'sanitize' to FALSE in the i18n_string options. Can everyone have a look and provide feedback? Thanks.
Comment #6
joel_osc CreditAttribution: joel_osc at OpenPlus commentedNote the same fix would also need to be applied the redirect url - I noticed query strings '&' being encoded too.
Comment #7
knalstaaf CreditAttribution: knalstaaf commentedI applied the fix in #5, and it seems to do the job (I'm using "No redirect (refresh current page)").
Thank you!
Comment #8
joseph.olstadHi joel_osc, your fix looks good, want to push it ? I fought with this issue for a long time , didn't know it still existed, glad to see you fixed it. I think we should publish a new release 4.6 with your fix.
would be "nice" if there was a simple test for this so to make sure this doesn't regress in the future.
Comment #9
joseph.olstadThere is a related issue about this that was closed a while back. From my previous observations, I18N_STRING_FILTER_XSS filters out quite a bit of html. Sanitize should be false either way. We don't want to convert html into plain text.
Comment #10
joseph.olstad@joel_osc , XSS_ADMIN allows more html tags, seeing as these fields are created in "admin" mode by the person setting up webform_localization, its in all likelihood better to use XSS_ADMIN which allows more html tags (is more permissive).
see patch
Comment #11
joseph.olstadpatch 10 or patch 11
Comment #16
joel_osc CreditAttribution: joel_osc at OpenPlus commentedGood call Joseph! Thanks for rolling the patch. Cheers.
Comment #17
joseph.olstadComment #19
joseph.olstadComment #21
fgjohnson@lojoh.ca CreditAttribution: fgjohnson@lojoh.ca commentedI applied this patch to 7.x-4.8... Should I use .dev?
Better - No double encoding of tags. :-)
After Patch 10 the French is stripping out tags between the first and last paragraph tag.
English Confirmation message
French Confirmation message (Stripped out some tags)
<p>Merci d’avoir soumis vos commentaires. Voici vos numéros de référence : Numéro de service : [node:nid] Numéro de la soumission : [submission:sid] <a class="printbtn btn btn-blue" href="/en/print">IMPRIMER </a></p>
webform_localization-html_tags_as_html-2758565-10.patch
.rej is 566 lines long.
webform_localization-html_tags_as_html-2758565-11.patch
.rej
Comment #22
RAWDESK CreditAttribution: RAWDESK for Colruyt Group Services commentedConfirming this patch worked by upgrading from 7.x-4.5 to 7.x-4.10