#1716098: Support HTML in the token rewrite? reopen.

I tried using [user:field_address] token that returns me an address field from addressfield / addressfield_tokens modules and I see below code in the node. How can we loosen the rules or can you add <span> to the good tags? May use a filter format that allows more tags?

Example:
<span class="first-name">MyFirstname</span> <span class="last-name">MyLastname</span>MyStreet 63<span class="postal-code">12345</span> <span class="locality">MyCity</span><span class="country">Germany</span>

Need to investigate with latest code if duplicate of #1768510: Single quotes in [entity:label] are shown as "&#039;".

Comments

hass’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev

Not a duplicate of #1768510: Single quotes in [entity:label] are shown as "&#039;". Still broken in latest GID clone.

hass’s picture

Normally the $text is:

<div class="addressfield-container-inline name-block"><span class="first-name">Firstname</span> <span class="last-name">Lastname</span></div><div class="street-block"><div class="thoroughfare">My street. 1</div></div><div class="addressfield-container-inline locality-block country-DE"><span class="postal-code">12345</span> <span class="locality">City</span></div><span class="country">Germany</span>

All DIV's are removed and the SPANs are shown as html tags.

hass’s picture

I guess #title is always checkplained. '#html' => TRUE seems to have no effect.

    $element = array(
      '#type' => 'link',
      '#title' => field_filter_xss($text),
      '#href' => $link,
      '#html' => TRUE,
    );
hass’s picture

Assigned: Unassigned »
hass’s picture

Title: HTML span's shown from [user:field_address] address field » HTML span's check_plain'ed and div's filtered with [user:field_address] address field
Status: Active » Needs review
StatusFileSize
new1.24 KB

Patch attached.

hass’s picture

hass’s picture

Cross patched. New reduced patch

dave reid’s picture

Status: Needs review » Needs work

Note that using <div> tags are not actually valid to use in <a> tags:
http://stackoverflow.com/questions/1827965/is-putting-a-div-inside-an-an...
http://stackoverflow.com/questions/1091739/html-div-in-link-problem

If anything I think I would only accept a patch that uses filter_xss() on the non-link output, but we can't allow any additional tags in the link text.

hass’s picture

Ok, but it works :-). Independed from the unsupported DIV inside the A... I need a link :-)

How can we solve the problem that the HTML code generated by the addressfield_tokens module works properly here? I'm not aware of any rule that say - module maintainers are not allowed to use DIV inside a token? How should we handle this in general?