Re: BUG #3735: Can't create xml-stylesheet processing instruction

From: Ben Leslie <benno(at)benno(dot)id(dot)au>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3735: Can't create xml-stylesheet processing instruction
Date: 2007-11-10 02:43:23
Message-ID: 20071110024323.GA8837@cse.unsw.edu.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri Nov 09, 2007 at 16:53:08 +0100, Peter Eisentraut wrote:
>Am Freitag, 9. November 2007 schrieb Ben Leslie:
>> # select xmlpi(name "xml-stylesheet");
>> ERROR: invalid XML processing instruction
>> DETAIL: XML processing instruction target name cannot start with "xml".
>
>Apparently I read the SQL spec a bit to strictly here. I've installed a fix
>into CVS.
>
>> The w3c XML 1.0 spec says that PIs starting with 'xml' are reserved.
>
>That's what I thought as well, but they actually only reserve names being
>exactly 'xml' modulo case differences.

Hi,

I've installed from CVS. It is closed, but now I've got another error.
As an example, here is some code that gives me the output I expected:

okdb=# select xmlroot(xmlpi(name "xsl-stylesheet"), version '1.0');
xmlroot
--------------------
<?xsl-stylesheet?>
(1 row)

If I know try this with but using the correct name "xml-stylesheet", the
output returned is null.

okdb=# select xmlroot(xmlpi(name "xml-stylesheet"), version '1.0');
xmlroot
---------

The reason for the bug is the new part of code in parse_xml_decl().
Specifically, utf8len is not initialised causing the problem.

A incomplete fix is changing it to be something along the lines of:

/* This means it's a PI like <?xml-stylesheet ...?>. */
utf8len = 4; /* FIXME: How do we know how many characters it could be?*/
utf8char = xmlGetUTF8Char(&p[5], &utf8len);
if (utf8char == -1) {
/* The libxml docs don't actually specify why you could have an error
here. Reading the source indicates an error would only occur in the
case that utf8len is not long enough */
printf("Error.. not sure what to do in this case?");
}
if (pg_xmlIsNameChar(utf8char))
goto finished;

Obviously, there are a lot of problems in the small number of lines of code,
in particular how to get the correct value for utf8len, and also what
to do in the error case.

Not ever having touched libxml or postgres code before I don't really know
the right patch.

Cheers,

Benno

(P.S: Please CC me, I'm not on the list.. yet).

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2007-11-10 03:19:44 Re: [BUGS] Nasty tsvector can make dumps unrestorable
Previous Message Gregory Stark 2007-11-10 00:13:31 Re: BUG #3737: lower/upper fails to match extended chars in LATIN1