Re: Importing sticky ntoes



Hi,

> There may be other problems, but I cannot send you the whole
> stickynotes_applet file. If you want to send me your patch fixing these,
> I'll be happy to beta test it.
> 
> By the way, I guess the problem is around line 297 of
> stickynoteimportnoteaddin.cpp:
> 
>   std::string noteXml = str(boost::format("<note-content><note-title>%
> 1%</note-title>\n\n"
>                                "%2%</note-content>") % title % content);
> 
> which makes libxml2 reparse already parsed xml.
> If what I just wrote is not plainly stupid, then maybe the cleanest
> solution would be to parse the stickynotes file without considering it
> xml (i.e. as regexps), extract notes bodies and _then_ pass them as
> "content"?


I was strugling with this issue, but it looks like I finally got to the
bottom of this.

Initially it look simple, I simply passed title and content through
gnote::utils::XmlEncoder::encode(), but it didn't help. Apparantly, our
encoder does not encode :)

If I do:
xmlTextWriterWriteString(writer, "a<b&c");

which is what encode() currently does, the string is written to xml as
is!

However, if I do:
xmlTextWriterStartElement(writer, "x");
xmlTextWriterWriteString(writer, "a<b&c");
xmlTextWriterEndElement(writer);

I get a proper XML:
<x>a&lt;b&amp;c</x>


There is at least one more bug from this area:
gnote --new-note='a<b'

This should create a new note named "a<b", but I get a note with empty
content and similar XML parsing errors are printed to console.

I haven't found any note regarding changed xmlTextWriterWriteString in
libxml release notes. Looks like we've lived so long with this bug
present and weren't hit by it until now. 
Facinating...

-- 
Aurimas

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]