Jump to content

Page tree: Pages containing "<=" in the title get cut off (Core bug?)


schwarzdesign
 Share

Recommended Posts

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 ...

with-space.png

without-space.png

Link to comment
Share on other sites

  • 3 months later...

@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:

2020-06-27_105645.png.c94b3913bb990dfdd3918f3f65e836fd.png

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

@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

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 &lt; 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);
});

 

  • Like 3
Link to comment
Share on other sites

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...