If entry title contains '--' then RDF code breaks?

Found a bug? Tell us!!
Post Reply
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

If entry title contains '--' then RDF code breaks?

Post by zoran »

I posted an entry with '--' in the title.

That gives this RDF code in the page source:

Code: Select all

        <!--
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
                 xmlns:dc="http://purl.org/dc/elements/1.1/">
        <rdf:Description
                 rdf:about="http://www.kovacevic.nl/blog/feeds/ei_188.rdf"
                 trackback:ping="http://www.kovacevic.nl/blog/comment.php?type=trackback&entry_id=188"
                 dc:title=""The Internet Services Disruption" -- Web 2.0 by Microsoft"
                 dc:identifier="http://www.kovacevic.nl/blog/archives/188-The-Internet-Services-Disruption-Web-2.0-by-Microsoft.html" />
        </rdf:RDF>
        -->
Which renders ' -->' (i.e. end comment) just below the entry.

If I change the title of the entry and replace '--' with '-' then I get the correct RDF:

Code: Select all

        <!--
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
                 xmlns:dc="http://purl.org/dc/elements/1.1/">
        <rdf:Description
                 rdf:about="http://www.kovacevic.nl/blog/feeds/ei_188.rdf"
                 trackback:ping="http://www.kovacevic.nl/blog/comment.php?type=trackback&entry_id=188"
                 dc:title=""The Internet Services Disruption" - Web 2.0 by Microsoft"
                 dc:identifier="http://www.kovacevic.nl/blog/archives/188-The-Internet-Services-Disruption-Web-2.0-by-Microsoft.html" />
        </rdf:RDF>
        -->
Any ideas what is going wrong?

Regards,
Zoran
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: If entry title contains '--' then RDF code breaks?

Post by garvinhicking »

Yes, sadly the Browser is going wrong. It interprets "--" within a HTML comment string as "-->", which is of course not wanted.

I don't know why browsers do that, but there's not much that serendipity can do. We could replace "--" to "-", but then why should we? Using the "--" would be perfectly fine, and I'd rather not like to fix a thing that is not broken by design?

So I don't really know what to do - there are reasons to bypass the problem, but there are also reasons why such behaviour shouldn't be fixed in applicatins but rather in the browser(s)...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Re: If entry title contains '--' then RDF code breaks?

Post by zoran »

Okay, so its a Firefox bug. MSIE works fine. I'll check bugzilla and try to post a bug there.

Thanks!
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Re: If entry title contains '--' then RDF code breaks?

Post by zoran »

But before I do that ... ;)

I've made this minimal case:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>test</title>
</head>

<body>
<div>
        <!--
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:dc="http://purl.org/dc/elements/1.1/">
        <rdf:Description
                 dc:title="test -- test"
                 dc:identifier="test" />
        </rdf:RDF>
        -->
</div>
</body>
</html>
Trying to validate this at http://validator.w3.org/#validate-by-input gives these warnings and errors:

Code: Select all

# Warning  Line 14 column 34: S separator in comment declaration.

                 dc:title="test -- test"

This may happen if you have consecutive comments but did not close one of them properly. The proper syntax for comments is <!-- my comment -->.

?
# Error Line 14 column 35: invalid comment declaration: found name start character outside comment but inside comment declaration.

                 dc:title="test -- test"

?
# Info Line 10 column 8: comment declaration started here.

        <!--

# Error Line 16 column 17: end tag for element "rdf:RDF" which is not open.

        </rdf:RDF>

The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

If this error occured in a script section of your document, you should probably read this FAQ entry.
... which looks like either the w3 xml validator has the same bug as gecko, or the bug is in the code.

Any ideas?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: If entry title contains '--' then RDF code breaks?

Post by garvinhicking »

Hm, maybe then the HTML specification says that "--" within comments is forbidden? Do you know that maybe, or can find a RFC for that, or are able to read DTDs? :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
zoran
Regular
Posts: 71
Joined: Sun Jan 16, 2005 9:13 pm
Location: Amsterdam
Contact:

Re: If entry title contains '--' then RDF code breaks?

Post by zoran »

http://www.w3.org/TR/REC-xml/#dt-comment:

Code: Select all

[Definition: Comments MAY appear anywhere in a document outside other markup; in addition, they MAY appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. [b]For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.[/b]] Parameter entity references MUST NOT be recognized within comments.
Comments
[15]   	Comment	   ::=   	'<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
Well, that pinpoint where the bug is :)

How about using entities

Code: Select all

<!ENTITY minus    CDATA "−" -- minus sign, U+2212 ISOtech -->
http://www.w3.org/TR/REC-html40/sgml/en ... l#h-24.2.1

Drawback is that content will contain HTML characters. The good thing is that I can then use '--' in my entry titles ;)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: If entry title contains '--' then RDF code breaks?

Post by garvinhicking »

Hrm, I just looked at the template, and changing this in a good manor will be hard. The reason is that {$entry.title} is used within the template, so we need to use a different variable within the template to indicate a new $entry.rdf_title or so. That in turn means that new templates with this variable won't work on older serendipity versions.

Using an entity within the title might also raise other problems within templates or RSS feeds.

Well, I guess I have to sleep about that :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply