After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 172215 - XML Schema <any> with namespace "##other" is not working correctly
XML Schema <any> with namespace "##other" is not working correctly
Status: VERIFIED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-03-31 10:35 UTC by kbuchcik
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
any5_0.xsd (378 bytes, text/plain)
2005-03-31 10:36 UTC, kbuchcik
Details
any5_0.xml (174 bytes, text/plain)
2005-03-31 10:36 UTC, kbuchcik
Details

Description kbuchcik 2005-03-31 10:35:28 UTC
Please describe the problem:
If having a non-absent targetNamespace and using an <any> wildcard with the
namespace specifier "##other", elements bound to the targetNamespace are
incorrectly still let through. 

Such a negated wildcard is build via two transitions:

        (*|urn:some:ns) [Tr1]
       /                    \
[start]                      NULL [sink-state]
       \                     
        (*|*) [Tr2]          
                  \
                   [final state]    


The first transition [Tr1] tries to catch elements in the wrong namespace - to
lead them to a sink-state. The second [Tr2] lets through elements in all other
namespaces.

The regex does correctly identify the built automaton as a "sink-state"-case. 

The following seems to happen:
1. An invalid element is pushed.
2. The automaton reaches the "sink-state"
3. xmlRegExecPushString is called with NULL to finish the process
4. xmlRegExecPushString returns 0, since it somehow rollbacks the "sink-state"
   and finds a way to push the last invalid element through transition [Tr2],
   making it valid again.

Steps to reproduce:
I'll attach a test case.


Actual results:
xmllint --noout --schema any5_0.xsd any5_0.xml
any5_0.xml validates

Expected results:
I get the following with a workaround in xmlschemas.c:

xmllint --noout --schema any5_0.xsd any5_0.xml
Element 'boo': This element is not expected. Expected is one of ( {##other:urn:t
est:foo}* ).
any5_0.xml fails to validate

Does this happen every time?


Other information:
Comment 1 kbuchcik 2005-03-31 10:36:23 UTC
Created attachment 39490 [details]
any5_0.xsd
Comment 2 kbuchcik 2005-03-31 10:36:53 UTC
Created attachment 39491 [details]
any5_0.xml
Comment 3 kbuchcik 2005-04-05 16:06:58 UTC
The workaround is in the CVS now (xmlschemas.c).
Comment 4 kbuchcik 2005-04-19 15:13:07 UTC
Removed the workaround, since it was not working in every case.

We need somehow the transitions [Tr1] and [Tr2] not to be handled as a "choice":
if [Tr1] leads to the sink state, the automaton must not rollback, but stay
captured in the sink state.
Comment 5 Daniel Veillard 2005-04-28 15:18:14 UTC
More work at the automaton level needed apparently then

Daniel
Comment 6 kbuchcik 2005-07-01 08:47:44 UTC
As of xmlschemas.c revision 1.134 a temporary workaround exists for a scenario
where the minOccurs and maxOccurs of the <any> wildcard are both 1. For other
min/maxOccurs values this bug is still existent.
Comment 7 Daniel Veillard 2005-07-19 19:15:59 UTC
This is fixed in CVS, this required extending the automata to handle
transition for non-values, but this is the only right way to fix this
unfortunately :-)

I added a number of regression tests,

  thanks,

Daniel
Comment 8 Daniel Veillard 2005-09-05 09:00:00 UTC
This should be closed by release of libxml2-2.6.21,

  thanks,

Daniel