Twig icon indicating copy to clipboard operation
Twig copied to clipboard

Upper formats as html-specialchars

Open scansec opened this issue 11 years ago • 8 comments

When using |upper on a variable, "DÆK OG FÆLGE" is showen as "DÆK OG FÆLGE"

When not using filers, or using capatilize it works fine.

using twig/twig (v1.16.2)

scansec avatar Dec 09 '14 20:12 scansec

The issue seems to be that you apply the upper filter after escaping the HTML, which makes the HTML entity uppercased, thus breaking it (or maybe it gets escaped a second time)

stof avatar Jan 18 '15 15:01 stof

@scansec Can you confirm @stof intuition?

fabpot avatar Jan 25 '15 12:01 fabpot

@fabpot , no, due to that it works using the filter capatilize, but not when using the filter uppercase.

scansec avatar Jan 25 '15 16:01 scansec

Your original string is dæk og fælge and not dæk og fælge as you may see in your browser, because your browser interprets the æ symbol to æ. The uppercase value for æ is Æ and not Æ, so if you're applying uppercase filter on the whole string, you're breaking those HTML entities.

Capitalize filter only puts the first string's character to uppercase, so entities are not affected and you do not see any issue.

ninsuo avatar Jan 25 '15 16:01 ninsuo

Closing as there is no feedback. @scansec Feel free to reopen with a reproducible test case if you still have the problem. Thanks.

fabpot avatar Mar 06 '15 07:03 fabpot

Here's your test case:

https://twigfiddle.com/93xg4u

dommmel avatar Sep 06 '17 10:09 dommmel

@dommel You need to apply the raw filter after the upper filter: https://twigfiddle.com/93xg4u/2

xabbuh avatar Sep 06 '17 10:09 xabbuh

I see @xabbuh, thanks!

dommmel avatar Sep 06 '17 10:09 dommmel