Textpattern Forum

You are not logged in. Register | Login | Help

#21 2005-11-08 09:04:05

Etz Haim
Plugin Author
From: Karlstad, Sweden
Registered: 2005-01-24
Posts: 262
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

Yes, it is invalid. Just think what a combination of < and > could do, ie. in a more complex formula.

Last edited by Etz Haim (2005-11-08 09:05:21)

Offline

#22 2005-11-13 18:30:37

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,979
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

Etz Haim wrote:

<blockquote>Yes, it is invalid. Just think what a combination of < and > could do, ie. in a more complex formula.</blockquote>

when you say “a more complex formula”, are you talking about math formulae and logical formulae as the “a > b” you put as example in the first post?

My argument

if you need to write more complex formulae, surely you will need more symbols than simple <, > and =.
For sure, you will want to use formulae symbols like:

<big>*&supe; &ge; &equiv; &ne; &phi; &infin; &fnof; &harr;*</big> and many other symbols.

Do you have those symbols in your keyboard? I suppose you dont, so, how will you put them in your article title?
You will do the same I did to display those symbols in this post:
you will type them as HTML entities:

<code>&amp;supe; &amp;ge; &amp;equiv; &amp;ne; &amp;phi; &amp;infin; &amp;fnof; &amp;harr;</code>

So, this is my logic: if you need to type those symbols as HTML entities, why wont you type the < and > also as HTML entities? wont you type them as entities because you have them in your keyboard?. Lazy boy! ;)

Well, as a second argument, I would ask: arent math/logical formulae out of the scope of a simple article title? I want to mean: arent formulae a very rare case in article titles? wont be the need of formulae in titles just to a very small niche of txp users?
Is it very common to have “a > b”-like titles in your posts? I dont know, I’m just asking.

One counterargument to my argument

Sure, many users will use > and < in a context that is not a math formulae.
Article titles like “It’s my birthday > buy me a present!” ¿are of common use? (I dont know).
If user wants to type > and < directly from the keyboard, they should accept they will have invalid code in their <code><title></code> and also in his site.

Finally, I ask, have we lost the power of using HTML elements in our article/section/category titles just for escaping <, > and &?

I’m asking standing at my own ignorance, because I dont know how dangerous could be to have a few unescaped characters in our code.
And there is no need to expect that TXP do the job of escaping those characters: just learn to type <code>&amp;lt;</code>, <code>&amp;gt;</code> and that’s all you need to know.

Thanks <small>and excuse my barbarian english and some lack of consistency behind my logic</small>


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#23 2005-11-13 23:21:50

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

That’s why unicode is for. Title are supposed to handle complex glyph.

How to type them ? Well the same way you type them everywhere… if one needs help, upm_quicktags does this wonderfully.

Offline

#24 2005-11-13 23:31:07

zem
Developer emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

maniqui: it’s still not clear to me what you’re proposing. Send us some code that does what you’re suggesting and we’ll take a look at it.

Otherwise, I think this has strayed a long way from being a bug report.


Alex
tstate

Offline

#25 2005-11-14 04:19:58

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,979
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

> zem wrote:

> maniqui: it’s still not clear to me what you’re proposing. Send us some code that does what you’re suggesting and we’ll take a look at it.

Sorry, “pale face”, me not speak very good english ;)

I will try to summarize:

In TXP 4.0.1, it was posible to use HTML elements (acronym, strong, em, etc) in the article titles (and even in section/category titles). And that was a nice feature that now we dont have in 4.0.2.
Now (4.0.2), if you use HTML elements in titles, the < and > are escaped and so, you get article titles like “I love < abbr title=“Textpattern”>TXP< /abbr>”, when before (4.0.1) you got a nice title like “I love <abbr title=“Textpattern”>TXP</abbr>”.
The same applies to section/category titles. Before, you can use HTML elements in them, now you cant (and that was very very cool, because it added lot of flexibility… think: you can have spans or strong tags in the section title!)

So, as I see it, TXP have lost an interesting feature.
And as far as I understand, TXP lost that feature for one reason: to have valid content in the <code><title></title></code> tag.

You cannot use a > or a < in the <code><title></code>, but you can have <code>&amp;lt;</code> or <code>&amp;gt;</code>

And the problem started when someone used <code><txp:page_title /></code>.
In an individual article context, that txp tag will include the article title in the <code><title></code> tag.
So, if you have a title like “a > b”, you will get invalid code (a warning) if the “>” is not escaped in the <code><title></code>.

So, between 4.0.1 and 4.0.2, the change was to escape any > and < in article/section/category title. The result: now you have valid content in <code><title></code> but you cant use HTML elements in article/section/category titles. In 4.0.1, “out of the box”, if you use HTML elements you will get invalid content in title element, but that is why I wrote the tip about using sab_striphtml to strip HTML elements from any article/section/category title.

My thoughs/suggestion: how many users use < and > in the article titles? how many users writes formulae in article titles? I dont know, but I would bet they are just a minority.
Of course it’s nice to write formulae symbols in article titles, but if you want to do that, then manually encode your special characters. Write <code>&amp;lt;</code> instead of typing <, write <code>&amp;gt;</code> instead of > and etcetera.

That way, if you revert back to the behaviour of 4.0.1, you can use the HTML elements in article titles (and strip them from the <code><title></code>). Also, when you need to use special characters in titles (< > and many more) you type them as HTML entities references.

I think I have been not very clear again… ¿no?
Next time I will try to write no more than two paragraphs, I promise.
Thanks!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#26 2005-11-14 04:43:03

zem
Developer emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

Sorry, “pale face”, me not speak very good english ;)

Your English isn’t the problem. Forgive my stubborness, I’m trying to find the “what” amongst the “why”.

TXP lost that feature for one reason: to have valid content in the <title></title> tag.

Don’t forget feeds. And remember, entities that are valid in HTML aren’t necessary valid in XML.

My thoughs/suggestion: how many users use < and > in the article titles? how many users writes formulae in article titles?

How many use HTML in article titles? (This I don’t know either, but I do know we received more reports about the lack of encoding prior to 4.0.2, than we have about the presence of it now)

Now, if you were arguing for Textile in article titles, we might be on to something.


Alex
tstate

Offline

#27 2005-11-14 05:22:32

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

zem wrote:
Now, if you were arguing for Textile in article titles, we might be on to something.

Hey, I made that request months ago !

;->

Last edited by Jeremie (2005-11-14 05:22:55)

Offline

#28 2006-03-24 19:02:42

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,057
Website

Re: [issue] Special HTML characters (<, >, &) in article titles

Ok, after a frustrating time with an &amp; character in my title. I found the following approach to work.

<code><title><txp:php>echo htmlspecialchars(page_title());</txp:php></title></code>

Am I missing something? Is there a good reason why this is bad? At least it validates now.

Aside: Oddly enough I found the solution ‘htmlspecialchars()’ from zem’s excellent “how to make a plugin” series, otherwise I’m a complete php dozer.

Last edited by mrdale (2006-03-24 19:04:59)

Offline

#29 2011-08-02 23:39:13

wavesource
Member
From: Australia
Registered: 2011-08-02
Posts: 21

Re: [issue] Special HTML characters (<, >, &) in article titles

This is an old thread, but I found this solution useful, building on mrdale’s comment, allowing me to push HTML to a title in a specific form:

<txp:php>echo html_entity_decode(str_replace(‘&#160;’,’ ‘,title()));</txp:php>

Offline

#30 2011-12-29 23:23:20

NyteOwl
Moderator
From: Nova Scotia, Canada
Registered: 2005-09-24
Posts: 539

Re: [issue] Special HTML characters (<, >, &) in article titles

Is this issue still afloat? I hacked my old 4.0.3 so that I could use ampersands in the article titles directly. (I don’t use Textile)


Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;

Offline

Board footer

Powered by FluxBB