saveDocument converts ©

I need some Mozilla help:

My extension, Launchy, gives the user the ability to view the source of a webpage in an editor of the users choice. To do this I use the saveDocument function. But when I do this, HTML entities like fx © gets converted into a real copyright char.

I thought that if I just use the ENCODE_FLAGS_RAW flag it would work. But it doesn't seems to work.

My code:
const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(nsIWBP);
persist.persistFlags = nsIWBP.PERSIST_FLAGS_FROM_CACHE | nsIWBP.PERSIST_FLAGS_NO_CONVERSION | nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES | nsIWBP.PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS | nsIWBP.PERSIST_FLAGS_DONT_FIXUP_LINKS | nsIWBP.FLAGS_DONT_CHANGE_FILENAMES;
var encodingFlags = nsIWBP.ENCODE_FLAGS_RAW;
persist.saveDocument(doc, f, null, null, encodingFlags, 0);

Can anybody help? If you can, please can leave a comment here or add a comment to the bug report here.

You can test it yourself if you install my Launchy extension and then right click on a gemal.dk page and say Launchy -> View Source in blabla. Then the © symbol at the end of the source will be converted, which it shouldn't.


September 13, 2004 04:18 PM | Posted in Mozilla

Ads:

Back Next

3 Comments

I came across this bug today:
http://bugzilla.mozilla.org/show_bug.cgi?id=258673

Maybe it is relevant.

Comment by Nick Thomas at September 13, 2004 06:07 PM | Permalink

It seems that the solution is:
var encodingFlags = nsIWBP.ENCODE_FLAGS_RAW | nsIWBP.ENCODE_FLAGS_ENCODE_W3C_ENTITIES;

Site icon Comment by Henrik Gemal at September 13, 2004 09:44 PM | Permalink

Henrik, I think you might want to be passing in ENCODE_FLAGS_ENCODE_HTML_ENTITIES, not PERSIST_FLAGS_NO_CONVERSION. I don't have a way to test this really, but if you take a look at these lines it looks more like what you want:

http://lxr.mozilla.org/mozilla/source/content/base/public/nsIDocumentEncoder.h#166
http://lxr.mozilla.org/mozilla/source/embedding/components/webbrowserpersist/public/nsIWebBrowserPersist.idl#235
http://lxr.mozilla.org/mozilla/source/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp#459

NO_CONVERSION is not referenced anywhere in the saveDocument function, whereas ENCODE_HTML is. Hope this works for you!

Comment by Jon Henry at September 13, 2004 09:50 PM | Permalink

Post a comment




Remember Me?




Please enter the security code you see here

.
You're here: Home - saveDocument converts ©
Get the Mozilla Firefox browser