The current D8 token replacement routine automatically HTML escapes all tokens before returning to the calling routine. This means for auto_entitylabel entity titles will include HTML escape characters which are not usually wanted. It would be nice to have an option on the 'Automatic Label Generation' form to reverse the HTML escape when using tokens in labels. The Token::replace page suggests using PlainTextOutput::renderFromHtml() for this.

Comments

Dippers created an issue. See original summary.

dippers’s picture

You can reverse the html escape using PHP option:

<?php return \Drupal\Component\Render\PlainTextOutput::renderFromHtml('{{ token string }}'); ?>
sonvir249’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

Added a patch for the above functionality.
Please review the patch.

Thanks!

gg24’s picture

Status: Needs review » Needs work
+++ b/src/AutoEntityLabelManager.php
@@ -147,7 +147,13 @@ class AutoEntityLabelManager implements AutoEntityLabelManagerInterface {
+    //Escape special charaters enabled

One space before Escape and full stop in after comment.

sonvir249’s picture

Status: Needs work » Needs review
StatusFileSize
new1.36 KB

Hi Gaurav, changes done as suggested.

Thank you!

gg24’s picture

Status: Needs review » Reviewed & tested by the community

Hi @sonvir249,

The patch applies cleanly and works as intended. Hence marking this as RTBC.
Thanks for you efforts!

Thanks!

purushotam.rai’s picture

Status: Reviewed & tested by the community » Needs work

I feel the code should go in generateLabel protected method instead of setLabel.

Thanks and Regards

sonvir249’s picture

Status: Needs work » Needs review
StatusFileSize
new1.47 KB

Hi @purushotam.rai,
Changes done as suggested.

Thank you!

purushotam.rai’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.
Thanks folks for all your efforts.

purushotam.rai’s picture

Status: Reviewed & tested by the community » Fixed

Marking the issue as fixed, will definitely be included in next release.

Thanks and Regards

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.