You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 24, 2022. It is now read-only.
I observed this in the Popular books list.
One of the books was showing the name ")" in the list. When I opened the details section for that book, it showed a much longer name: "Junie B. Jones Loves Handsome Warren (Junie B. Jones #7)".
It turns out that the response from the server is correct, but when parsing the XML, we set the title (and all other fields) incorrectly.
According to the SAXParser documentation, the characters function can be called multiple times for a single element, but the current implementation just sets the title or author name as is.
So in this case, there were two callbacks to characters function for the title:
"Junie B. Jones Loves Handsome Warren (Junie B. Jones #7", and
")"
So this code is incorrect:
Instead of setting the title on getting the characters, it should collect those characters in a StringBuilder and then on endElement, set the string in that StringBuilder to title, etc.
I observed this in the Popular books list.
One of the books was showing the name ")" in the list. When I opened the details section for that book, it showed a much longer name: "Junie B. Jones Loves Handsome Warren (Junie B. Jones #7)".
It turns out that the response from the server is correct, but when parsing the XML, we set the title (and all other fields) incorrectly.
According to the
SAXParser
documentation, the characters function can be called multiple times for a single element, but the current implementation just sets the title or author name as is.So in this case, there were two callbacks to characters function for the title:
"Junie B. Jones Loves Handsome Warren (Junie B. Jones #7", and
")"
So this code is incorrect:
Instead of setting the title on getting the
characters
, it should collect those characters in aStringBuilder
and then onendElement
, set the string in thatStringBuilder
to title, etc.Stackoverflow discussion: http://stackoverflow.com/questions/4567636/java-sax-parser-split-calls-to-characters
The text was updated successfully, but these errors were encountered: