I originally posted this issue in the token_filter queue here: #1558792: String type variables being wrapped with <pre></pre> tags when displayed with tokens

Dave Reid pointed me in the right direction and I confirmed that this problem appears when using variable-7.x-1.2. It does not exist in variable-7.x-1.1.

Variables defined as strings, like [variable:site_name], are being wrapped with <pre></pre> tags when they are displayed with tokens in blocks and content areas. Variables defined as text, like [variable:site_slogan], display without the <pre></pre> wrappers. The only filter I have enabled for the text format in use is the token filter. Is there a way to prevent this from happening?

Comments

bforchhammer’s picture

Looks like the string variable type is missing a format callback, and therefore falls back to variable_format_unknown (which wraps content into pre tags). For the text type, the callback is set as variable_format_text...

You can implement hook_variable_info_alter() to set the format callback for the site_name variable; I'm not sure whether this should be changed globally for all 'string' types...

cameron prince’s picture

Thanks for the info, but I would argue that this should be changed globally because: 1) This is new behavior that breaks the upgrade path for some users, 2) Formatting should be left to other functions based on the needs of the programmer, 3) Inconsistent display of variable values in the UI.

For now, I've reverted to v7.x-1.1.

jose reyero’s picture

Status: Active » Fixed

Added better formatting for both 'text' and 'string' types. Both can have an 'allowed tags' property. If empty, the first will default to filter_xss_admin, the second to check_plain.

Status: Fixed » Closed (fixed)

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