XMLPullParser hex bug
Hello everybody, I found a bug while playing with the XMLPullParser: When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error. I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase: If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...] However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception. The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'. Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1. The following two test cases show the problem. The first one shows the correct behavior: XMLPullParserTest>>testASCIIEntity | parser | parser := XMLPullParser parse: ' <tag contents="one two" />'. self assert: (parser next at: #contents) equals: (Character lf join: #(one two)) The second one shows the error: XMLPullParserTest>>testUnicodeEntity | parser | parser := XMLPullParser parse: ' <tag contents="one two" />'. self assert: (parser next at: #contents) equals: (Character lf join: #(one two)) I hope it is clear enough. I can also commit the fix myself, if you give me write access. Thanks, Tommaso
Tommaso I can give you access to the repository if you send me your SmalltalkHub user name. Cheers, Hernán 2014-09-08 6:28 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com>:
Hello everybody,
I found a bug while playing with the XMLPullParser:
When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error.
I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase:
If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...]
However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception.
The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'.
Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1.
The following two test cases show the problem. The first one shows the correct behavior:
XMLPullParserTest>>testASCIIEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
The second one shows the error:
XMLPullParserTest>>testUnicodeEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
I hope it is clear enough. I can also commit the fix myself, if you give me write access.
Thanks, Tommaso
On 08/09/14 15:16, Hernán Morales Durand wrote:
Tommaso I can give you access to the repository if you send me your SmalltalkHub user name. Cheers,
Hernán
Sure, it is dalsat Thanks, Tommaso
2014-09-08 6:28 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>:
Hello everybody,
I found a bug while playing with the XMLPullParser:
When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error.
I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase:
If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...]
However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception.
The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'.
Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1.
The following two test cases show the problem. The first one shows the correct behavior:
XMLPullParserTest>>testASCIIEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
The second one shows the error:
XMLPullParserTest>>testUnicodeEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
I hope it is clear enough. I can also commit the fix myself, if you give me write access.
Thanks, Tommaso
Done. Cheers, Hernán 2014-09-08 10:18 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com>:
On 08/09/14 15:16, Hernán Morales Durand wrote:
Tommaso I can give you access to the repository if you send me your SmalltalkHub user name. Cheers,
Hernán
Sure, it is dalsat Thanks,
Tommaso
2014-09-08 6:28 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com
<mailto:tommaso.dalsasso@gmail.com>>:
Hello everybody,
I found a bug while playing with the XMLPullParser:
When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error.
I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase:
If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...]
However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception.
The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'.
Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1.
The following two test cases show the problem. The first one shows the correct behavior:
XMLPullParserTest>>testASCIIEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
The second one shows the error:
XMLPullParserTest>>testUnicodeEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
I hope it is clear enough. I can also commit the fix myself, if you give me write access.
Thanks, Tommaso
I uploaded the changes. I did not notice the development package, so i uploaded the changes again to integrate your last changes (sorry for the garbage in the commit history). Since there was a package that was not in stable, I did not change the ConfigurationOf, is it safe to push it to stable? Thanks, Tommaso P.s.: of course I also added the test cases ;-) On 08/09/14 16:51, Hernán Morales Durand wrote:
Done.
Cheers,
Hernán
2014-09-08 10:18 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>:
On 08/09/14 15:16, Hernán Morales Durand wrote:
Tommaso I can give you access to the repository if you send me your SmalltalkHub user name. Cheers,
Hernán
Sure, it is dalsat Thanks,
Tommaso
2014-09-08 6:28 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com> <mailto:tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>>:
Hello everybody,
I found a bug while playing with the XMLPullParser:
When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error.
I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase:
If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...]
However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception.
The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'.
Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1.
The following two test cases show the problem. The first one shows the correct behavior:
XMLPullParserTest>>testASCIIEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
The second one shows the error:
XMLPullParserTest>>testUnicodeEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
I hope it is clear enough. I can also commit the fix myself, if you give me write access.
Thanks, Tommaso
I reviewed your changes and they are ok, so I have uploaded a new ConfigurationOfXMLPullParser with your changes as stable with version 1.4 and development as 1.5. All test pass in 3.0 loading from ConfigurationBrowser. Thanks for the fix Tommaso, Hernán 2014-09-08 19:46 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com>:
I uploaded the changes.
I did not notice the development package, so i uploaded the changes again to integrate your last changes (sorry for the garbage in the commit history). Since there was a package that was not in stable, I did not change the ConfigurationOf, is it safe to push it to stable?
Thanks, Tommaso
P.s.: of course I also added the test cases ;-)
On 08/09/14 16:51, Hernán Morales Durand wrote:
Done.
Cheers,
Hernán
2014-09-08 10:18 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>:
On 08/09/14 15:16, Hernán Morales Durand wrote:
Tommaso I can give you access to the repository if you send me your SmalltalkHub user name. Cheers,
Hernán
Sure, it is dalsat Thanks,
Tommaso
2014-09-08 6:28 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com> <mailto:tommaso.dalsasso@gmail.com
<mailto:tommaso.dalsasso@gmail.com>>>:
Hello everybody,
I found a bug while playing with the XMLPullParser:
When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error.
I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase:
If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...]
However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception.
The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'.
Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1.
The following two test cases show the problem. The first one shows the correct behavior:
XMLPullParserTest>>testASCIIEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
The second one shows the error:
XMLPullParserTest>>testUnicodeEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
I hope it is clear enough. I can also commit the fix myself, if you give me write access.
Thanks, Tommaso
Super! On 9/9/14 01:34, Hernán Morales Durand wrote:
I reviewed your changes and they are ok, so I have uploaded a new ConfigurationOfXMLPullParser with your changes as stable with version 1.4 and development as 1.5. All test pass in 3.0 loading from ConfigurationBrowser. Thanks for the fix Tommaso,
Hernán
Ciao tommaso add a test :) On 8/9/14 15:18, Tommaso Dal Sasso wrote:
On 08/09/14 15:16, Hernán Morales Durand wrote:
Tommaso I can give you access to the repository if you send me your SmalltalkHub user name. Cheers,
Hernán
Sure, it is dalsat Thanks,
Tommaso
2014-09-08 6:28 GMT-03:00 Tommaso Dal Sasso <tommaso.dalsasso@gmail.com <mailto:tommaso.dalsasso@gmail.com>>:
Hello everybody,
I found a bug while playing with the XMLPullParser:
When using XML entities encoded in hexadecimal the parser throws an exception. For example: is the hexadecimal encoding of which is the line feed. If you try to parse: '<tag contents="one two" />' you get a "Expected Number" error.
I investigated the problem, and found that it is caused by the method XMLPullParser>>readNumberBase:
If the base of the parsed number is not 10, it executes the following lines: numberString := self nextUpTo: $;. self stream skip: -1. [...]
However, the method nextUpTo: does not exist. A MNU is then raised and handled in nextCharReference: by a greedy "on: Error do: [:ex | self errorExpected: 'Number.']." thus causing the exception.
The solution is either to implement nextUpTo: or to change it in one of the two existing methods: nextUpToAll: or nextTrimmedBlanksUpTo: Example: numberString := self nextUpToAll: ';'.
Also, in the following line, it calls the accessor "stream", which does not exist and causes the same problem. The solution here is to change self stream skip: -1. into stream skip: -1.
The following two test cases show the problem. The first one shows the correct behavior:
XMLPullParserTest>>testASCIIEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
The second one shows the error:
XMLPullParserTest>>testUnicodeEntity | parser |
parser := XMLPullParser parse: ' <tag contents="one two" />'.
self assert: (parser next at: #contents) equals: (Character lf join: #(one two))
I hope it is clear enough. I can also commit the fix myself, if you give me write access.
Thanks, Tommaso
participants (3)
-
Hernán Morales Durand -
stepharo -
Tommaso Dal Sasso