schwarzdesign Posted March 6, 2020 Share Posted March 6, 2020 I have a curious situation with the page tree inside the ProcessWire Admin (UI Kit Theme). I have a page containing the string "<=" (without quotes), which causes the page title displayed in the page tree to be cut off. It only happens with exactly that directly beside each other. Out of curiosity, I tested both ">=" and "=>", those work fine. Attached are two screenshots showing the bug. If I put a space between the two characters, it works fine. Is this possibly a core bug? I had a quick look at the ProcessPageList module but didn't find anything related to this ... Link to comment Share on other sites More sharing options...
BitPoet Posted March 6, 2020 Share Posted March 6, 2020 That happens in ProcessPageListRender::___getPageLabel where strip_tags is invoked. So yes, it's a core issue. I'm not convinced strip_tags is necessary here at all since htmlspecialchars is called anyway. 2 1 Link to comment Share on other sites More sharing options...
schwarzdesign Posted March 6, 2020 Author Share Posted March 6, 2020 Thanks @BitPoet! In that case I would suggest simply calling strip_tags after htmlspecialchars, since strip_tags shouldn't remove the <= if it's properly entity encoded. @ryan Can you take a look? Should I open an issue on Github for this? Link to comment Share on other sites More sharing options...
horst Posted March 6, 2020 Share Posted March 6, 2020 2 hours ago, schwarzdesign said: Can you take a look? Should I open an issue on Github for this? YES! ? 1 Link to comment Share on other sites More sharing options...
schwarzdesign Posted March 6, 2020 Author Share Posted March 6, 2020 1 hour ago, horst said: YES! ? Done! I got issue #1111, neat ? 5 Link to comment Share on other sites More sharing options...
schwarzdesign Posted June 26, 2020 Author Share Posted June 26, 2020 @ryan Can you take a look at the issue? This bug is causing some issues with one of our projects, and it should be a 5 minute fix ... 1 Link to comment Share on other sites More sharing options...
Jan Romero Posted June 26, 2020 Share Posted June 26, 2020 As a workaround, just use ≤ ? 1 Link to comment Share on other sites More sharing options...
Robin S Posted June 26, 2020 Share Posted June 26, 2020 @schwarzdesign, I agree with your suggestion in the GitHub issue, but in terms of working around it double-check that you have the HTML Entity Encoder textformatter applied to the title field (it is by default after installing PW, and should be applied to all plain text fields). Because with that applied I don't experience the issue on a clean PW installation: 3 Link to comment Share on other sites More sharing options...
schwarzdesign Posted July 13, 2020 Author Share Posted July 13, 2020 @Jan Romero Thanks for the suggestion, I'll probably do that ^^ @Robin S Hm, curious. I have the HTML Entity Encoder turned off (because that is handled by Twig in our setup), but I'm still getting the cut-off title. I'm surprised you're getting different results. Not sure if this can be related to the textformatter, as the encoding is hard-coded inside ProcessPageListRender::___getPageLabel ... Link to comment Share on other sites More sharing options...
Robin S Posted July 13, 2020 Share Posted July 13, 2020 15 hours ago, schwarzdesign said: I have the HTML Entity Encoder turned off (because that is handled by Twig in our setup), but I'm still getting the cut-off title. Yes, what I'm saying is that if you have HTML Entity Encoder enabled for the Title field then you wont get the cut off title, because < will be encoded to < and so strip_tags() will leave it alone. The issue you've raised probably hasn't been noticed before because PW has the HTML Entity Encoder textformatter applied to the Title field by default and it's rare to disable it. If you're wanting to avoid double-encoding by Twig then until the issue is fixed you could just encode the title field before Page List renders the label: $wire->addHookBefore('ProcessPageListRender::getPageLabel', function(HookEvent $event) { $page = $event->arguments(0); $page->title = htmlspecialchars($page->title); }); 3 Link to comment Share on other sites More sharing options...
schwarzdesign Posted July 14, 2020 Author Share Posted July 14, 2020 @Robin S Oh I see, sorry I misread your reply the first time ? Enabling the textformatter is not an option for me because of the interferance with Twig. By the way I did consider turning Twig's autoescaping off and using textformatters instead, but in the end it's much easier to have Twig handle it instead of having to add the textformatter to every single field. So I'd say the issue is still valid, since there are use-cases for not wanting to use the formatter, even if they are not that common. Thanks for the workaround! I'll give that a try as well, either that or just use the proper smaller-than sign as suggested above ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now