[Expat-bugs] [ expat-Patches-673791 ] Error with xmlns:prefix=""

SourceForge.net noreply at sourceforge.net
Sun Jan 26 20:14:04 EST 2003


Patches item #673791, was opened at 2003-01-23 22:47
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=310127&aid=673791&group_id=10127

Category: None
Group: None
Status: Open
Resolution: Fixed
Priority: 6
Submitted By: Jeremy Kloth (jkloth)
Assigned to: Fred L. Drake, Jr. (fdrake)
>Summary: Error with xmlns:prefix="" 

Initial Comment:
When processing a document in namespace mode, the 
following document should be in error (according to XML 
Namespaces 1.0 Section 2): 
 
<?xml version='1.0'?> 
<docelem xmlns:pre=""/> 
 
However, it is being processed just fine. 
 
With the attached patch, this error is properly reported (only 
when namespace processing is enabled). 
 
I hope this can get in before the 1.95.6 release. 
 
Thanks, 
Jeremy Kloth 

----------------------------------------------------------------------

>Comment By: Karl Waclawek (kwaclaw)
Date: 2003-01-26 23:14

Message:
Logged In: YES 
user_id=290026

I found two additional flaws that show up when no 
startElementHandler is set for an element without attributes
(since storeAtts will not be called then):

1) Attributes will not be defaulted, and NS declarations based
on defaulted attributes will not be processed or checked, even
with Jeremy's fix. E.g. this document will pass without error:

<!DOCTYPE doc [
    <!ELEMENT doc (#PCDATA)>
    <!ATTLIST doc
        xmlns:pre CDATA "">
]>
<doc>some data</doc>

2) The element name will be stored but not prepared for 
proper namespace reporting (see ns_triplets), which is
a problem if there is an endElementHandler.

Similar arguments apply for empty elements that have no 
attributes.

So the solution is to always call storeAtts.
This may have a performance impact for the case
when no element handlers are set.

See attached files elmHandlers4.diff/txt.


----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-01-25 02:01

Message:
Logged In: YES 
user_id=3066

Committed Karl's latest patch as lib/xmlparse.c 1.106, with
most of his explanation in the commit message.  Portions
need to be incorporated as source comments as well.

Regression tests committed as tests/runtests.c 1.47.

Marked bug as fixed; still need to incorporate additional
source comments, so it remains open, with priority reduced
slightly.

----------------------------------------------------------------------

Comment By: Karl Waclawek (kwaclaw)
Date: 2003-01-25 01:17

Message:
Logged In: YES 
user_id=290026

Found already a bug in the fix:

In the case of a start element event, it does not store the
name, which is a problem if there is an endElementHandler.

Revised fix attached as elHandlers2.diif with the description
in elmHandlers2.txt.

----------------------------------------------------------------------

Comment By: Karl Waclawek (kwaclaw)
Date: 2003-01-24 23:49

Message:
Logged In: YES 
user_id=290026

I tested this against the OASIS test-suite and a few large
files with no problems. Hope it passes our suite of regression 
tests as well.

----------------------------------------------------------------------

Comment By: Karl Waclawek (kwaclaw)
Date: 2003-01-24 23:45

Message:
Logged In: YES 
user_id=290026

This patch does not work when no startElementHandler
is set, since then namespace declaration will not be 
processed - a recently documented limitation in Expat.

I have attached a new patch (on top of Jeremy's) which
should fix this, so that namespace declaration will
be processed and checked all the time.

Two files are attached:
- elmHandlers.txt: a brief overview/explanation
- elmHandlers.diff: the patch (against xmlparse.c rev. 1.105)

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-01-24 01:00

Message:
Logged In: YES 
user_id=3066

Jeremy:  Thanks for the update with regard to XML NS 1.1.  I
agree we don't need to worry about that yet; it's more
important to fix bugs with regard to XML 1.0 and the first
version of the namespaces spec.  See my previous note.

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-01-24 00:58

Message:
Logged In: YES 
user_id=3066

Ok, *now* I'm not happy.  I've done my "cvs up", and the
patch doesn't appear to have fixed the problem.  Perhaps I
don't have proper tests yet?  I've attached them to this
issue report.  I expected these tests to pass with current
CVS since Karl checked in Jeremy's patch.

I'll have to deal with this tomorrow; I'm too tired to go
trawling through this just yet.  The patched looked fine on
the surface; did it work for you?

----------------------------------------------------------------------

Comment By: Jeremy Kloth (jkloth)
Date: 2003-01-24 00:41

Message:
Logged In: YES 
user_id=38980

As far as the bug in the namespace spec goes, they addressed just 
his particular issue with XML NS 1.1.  However that would required XML 
1.1 processing which I'm not sure is something that is needed right 
now (although it is in canidate rec). 

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-01-24 00:20

Message:
Logged In: YES 
user_id=3066

What Karl didn't say was that he checked in the patch as
lib/xmlparse.c revision 1.105.  ;-)  I'll just avoid doing a
"cvs up" until the test is done -- should be soon.

----------------------------------------------------------------------

Comment By: Karl Waclawek (kwaclaw)
Date: 2003-01-24 00:08

Message:
Logged In: YES 
user_id=290026

Sorry, Fred.

I jumped the gun - wanted to finish it before going to bed.
It really looks OK, so I don't feel I risked too much.

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-01-24 00:03

Message:
Logged In: YES 
user_id=3066

I think you're right.  I haven't looked at the patch yet,
but the spec is (almost) clear about this.

I will note that I consider this more a bug in the namespace
spec than a desirable feature or constraint to test:  It
makes more sense (to me) to allow the use of xmlns:prefix=''
to "un-declare" the prefix (possibly making it an error of
some sort to un-declare a prefix that doesn't have an active
declaration).  But that's my opinion, not the letter of the
spec.

I'll mark this as accepted (for concept), and work up a test
case before committing anything.

----------------------------------------------------------------------

Comment By: Karl Waclawek (kwaclaw)
Date: 2003-01-23 23:37

Message:
Logged In: YES 
user_id=290026

Yes, it seems the NS specs do not allow a prefix name with 
an empty URI. This patch looks OK to me - if Fred agrees, I 
can commit it. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=310127&aid=673791&group_id=10127



More information about the Expat-bugs mailing list