[Gambas-devel] [Gambas-devel-svn] SF.net SVN: gambas:[8116] gambas/trunk/gb.xml/src

Tobias Boege taboege at ...176...
Sun Apr 2 20:41:11 CEST 2017

On Sun, 02 Apr 2017, tobiasboe at ...1... wrote:
> Revision: 8116
>           http://sourceforge.net/p/gambas/code/8116
> Author:   tobiasboe
> Date:     2017-04-02 14:59:50 +0000 (Sun, 02 Apr 2017)
> Log Message:
> -----------
> [GB.XML]
> * BUG: .XmlReader.Node.Attributes: Raise an error instead of segfault when an attribute does not exist
> * NEW: .XmlReader.Node.Attributes.Exist() is a new method to check if an attribute is present
> * BUG: XmlReader: Fix recognition of CDATA elements when their contents look like XML
> * BUG: XmlReader: Correctly detect ending sequence of CDATA and comment sections (reset the recognition state when the sequence is interrupted)

I just explained these changes to someone else and became aware that these 4
lines may not be specific enough as to where the errors were. Well, at least
the last two lines. The first line was simply a NULL pointer dereference and
prompted me to add the Exist() method.

The error from the third line could be triggered by a CDATA node such as:


Entering a CDATA node sets inCDATA = true, but this state wasn't considered
in nearly enough places. Before this commit, the <b> tag inside CDATA would
have been found (although it should have been ignored), the CDATA node
discarded and a <b> node reported instead.

The fourth line's error was revealed by a CDATA node like:

  <![CDATA[Text with a "]" inside]]>

As I understood the previous code, it would *not* search for the exact
sequence "]]>" to terminate a CDATA node but it would only *count* "have
I seen one ']'?", "have I seen two ']'?" and "have I seen a '>" after that?"
which results in the first occurence of "]" being eaten and the last
occurence being treated as a superfluous "]" character. For a superfluous
character you chose to append it to the end of the CDATA string, so the
above XML would produce a CDATA node with value

  Text with a "" inside]


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the Devel mailing list