Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Apostrophes/single quotes in article titles
Hi.
I’m using this in an article form to output some footer links in a ul:
<li><txp:permlink title='<txp:title /> was posted <txp:posted format="since" />'><txp:title /></txp:permlink></li>
…which outputs something like this on hover (article title in this case is I like hot toast):
I like hot toast was posted 4 hours ago
This is great, and exactly what I was expecting. However, if title contains an apostrophe, the hover now looks like this (article title in this case is I ate Stef's hot toast):
I ate Stef’s hot toast was posted 3 hours ago
Which is not so great. Is there a way to change the ' to an apostrophe? I was wondering if rah_replace would do it, but it seems a little overkill for the task.
Thank you in advance.
Last edited by gaekwad (2012-09-15 11:17:25)
Offline
Re: Apostrophes/single quotes in article titles
If rah_replace is already installed on the site, it’s fine to use it here. Otherwise, I can not find anything better than title='<txp:php>echo str_replace("' ;", "''", title(array()));</txp:php> was posted <txp:posted format="since" />'
Edit: delete the space between ' and ;, textile is stronger than me.
Last edited by etc (2012-09-14 13:36:08)
Offline
Re: Apostrophes/single quotes in article titles
Thank you, Oleg — rah_replace is already installed, so I’ll go ahead and use that.
Offline
#4 2012-09-14 17:13:47
- makss
- Plugin Author
- From: Ukraine
- Registered: 2008-10-21
- Posts: 355
Re: Apostrophes/single quotes in article titles
or use double quotes
<a href="<txp:permlink />" title="<txp:title />" ><txp:title /></a>
but then the title should be no double quotes.. :)
Last edited by makss (2012-09-14 17:14:28)
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
Re: Apostrophes/single quotes in article titles
makss wrote:
or use double quotes
Amazing, nice one!
Offline
Re: Apostrophes/single quotes in article titles
makss wrote:
or use double quotes
Hi makss.
Thank you for your reply. The problem I have with double quotes is parsing <txp:posted format="since" /> as it contains double quotes and is important to the output. I can’t test it right now, but would this work:
<li><txp:permlink title=”<txp:title /> was posted <txp:posted format=‘since’ />”><txp:title /></txp:permlink></li>
Last edited by gaekwad (2012-09-15 10:51:50)
Offline
Re: Apostrophes/single quotes in article titles
gaekwad wrote:
I can’t test it right now, but would this work:
<li><txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink></li>
Yes, it works, and that’s amazing. Not this one, but
<a href="<txp:permlink />" title="<txp:title /> was posted <txp:posted format='since' />" ><txp:title /></a>
will.
Last edited by etc (2012-09-15 11:16:18)
Offline
Re: Apostrophes/single quotes in article titles
etc wrote:
Yes, it works, and that’s amazing. Txp parser does marvels.
Thank you again, Oleg – I am very grateful for your assistance.
Offline
Re: Apostrophes/single quotes in article titles
Sorry, I was too fast. Actually, this one works too:
<txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink>
Txp parser does marvels.
Last edited by etc (2012-09-15 11:43:38)
Offline
Re: Apostrophes/single quotes in article titles
<txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink>
That shouldn’t be working, AFAIK.
Parsing tags in tags require simple quotes (at least, for a one-level depth).
The above line should be:
<txp:permlink title='<txp:title /> was posted <txp:posted format="since" />'><txp:title /></txp:permlink>
Offline
Re: Apostrophes/single quotes in article titles
maniqui wrote:
<txp:permlink title='<txp:title /> was posted <txp:posted format="since" />'><txp:title /></txp:permlink>
Thanks, Julián, that’s good to know — exactly what I was using in my opening post.
Offline
Re: Apostrophes/single quotes in article titles
maniqui wrote:
<txp:permlink title="<txp:title /> was posted <txp:posted format='since' />"><txp:title /></txp:permlink>
That shouldn’t be working, AFAIK.
That’s what I thought too, but I’m testing and retesting – it works. Could somebody confirm?
Offline
Re: Apostrophes/single quotes in article titles
etc wrote:
That’s what I thought too, but I’m testing and retesting – it works. Could somebody confirm?
As Julián says, it shouldn’t work. If it works, you have some type of extra parser call, an additional parser and/or unsanitizer somewhere running, most likely doing of a plugin.
When double quotes are used, the contents are treated and returned as it is. Nothing is parsed. Permlink tag also returns contents sanitized, so there is no change them being parsed by anything after that point. Normally you would need to use single quotes when an attribute value contains tags.
In other words, if the double quoted values are parsed even when sanitized, I would advice looking into what causes that ASAP if you use same plugins/code on live installations. Because if that is truly happening, you may have some pretty serious security issue laying there. If that same happens to user-defined content (e.g. search query value), well, that’s no good.
Last edited by Gocom (2012-09-15 20:44:14)
Offline
Re: Apostrophes/single quotes in article titles
Gocom wrote:
As Julián says, it shouldn’t work. If it works, you have some type of extra parser call, an additional parser and/or unsanitizer somewhere running, most likely doing of a plugin.
Guys, I agree it shouldn’t work, and it doesn’t on another localhost site, but it works on at least one of them (4.4.1 on wamp). Globally disabled plugins, php, installed vanilla page/article forms, even emptied cache – it’s still there. Even funnier: <txp:permlink title='<txp:title />'><txp:title /></txp:permlink> gives me true quotes in tooltip, not ' ; or " ;.
I have changed one line in publish.php, but it has nothing to do with parsing. That’s weird.
Edit: and it does not work on the remote from which the site has been imported, though they have diverged since.
Last edited by etc (2012-09-16 09:39:55)
Offline
Re: Apostrophes/single quotes in article titles
Looks like this weirdness happens only with the title attribute of <txp:permlink />, and only in 4.4.1. I have tested other tags/attributes – everything works as expected there.
Offline