mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 997030 - Don't encodeURI twice in bookmarks.html. r=mano
This commit is contained in:
parent
57bb73df1c
commit
ebdf84621f
@ -113,6 +113,14 @@ function escapeHtmlEntities(aText) {
|
||||
.replace("'", "'", "g");
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides URL escaping for use in HTML attributes of the bookmarks file,
|
||||
* compatible with the old bookmarks system.
|
||||
*/
|
||||
function escapeUrl(aText) {
|
||||
return (aText || "").replace("\"", "%22", "g");
|
||||
}
|
||||
|
||||
function notifyObservers(aTopic, aInitialImport) {
|
||||
Services.obs.notifyObservers(null, aTopic, aInitialImport ? "html-initial"
|
||||
: "html");
|
||||
@ -1087,10 +1095,10 @@ BookmarkExporter.prototype = {
|
||||
_writeLivemark: function (aItem, aIndent) {
|
||||
this._write(aIndent + "<DT><A");
|
||||
let feedSpec = aItem.annos.find(anno => anno.name == PlacesUtils.LMANNO_FEEDURI).value;
|
||||
this._writeAttribute("FEEDURL", encodeURI(feedSpec));
|
||||
this._writeAttribute("FEEDURL", escapeUrl(feedSpec));
|
||||
let siteSpecAnno = aItem.annos.find(anno => anno.name == PlacesUtils.LMANNO_SITEURI);
|
||||
if (siteSpecAnno)
|
||||
this._writeAttribute("HREF", encodeURI(siteSpecAnno.value));
|
||||
this._writeAttribute("HREF", escapeUrl(siteSpecAnno.value));
|
||||
this._writeLine(">" + escapeHtmlEntities(aItem.title) + "</A>");
|
||||
this._writeDescription(aItem, aIndent);
|
||||
},
|
||||
@ -1109,7 +1117,7 @@ BookmarkExporter.prototype = {
|
||||
}
|
||||
|
||||
this._write(aIndent + "<DT><A");
|
||||
this._writeAttribute("HREF", encodeURI(aItem.uri));
|
||||
this._writeAttribute("HREF", escapeUrl(aItem.uri));
|
||||
this._writeDateAttributes(aItem);
|
||||
yield this._writeFaviconAttribute(aItem);
|
||||
|
||||
@ -1152,7 +1160,7 @@ BookmarkExporter.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
this._writeAttribute("ICON_URI", encodeURI(favicon.uri.spec));
|
||||
this._writeAttribute("ICON_URI", escapeUrl(favicon.uri.spec));
|
||||
|
||||
if (!favicon.uri.schemeIs("chrome") && favicon.dataLen > 0) {
|
||||
let faviconContents = "data:image/png;base64," +
|
||||
|
@ -0,0 +1,37 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* Checks that we don't encodeURI twice when creating bookmarks.html.
|
||||
*/
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function() {
|
||||
let uri = NetUtil.newURI("http://bt.ktxp.com/search.php?keyword=%E5%A6%84%E6%83%B3%E5%AD%A6%E7%94%9F%E4%BC%9A");
|
||||
let bm = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
|
||||
uri,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"bookmark");
|
||||
|
||||
let file = OS.Path.join(OS.Constants.Path.profileDir, "bookmarks.exported.997030.html");
|
||||
if ((yield OS.File.exists(file))) {
|
||||
yield OS.File.remove(file);
|
||||
}
|
||||
yield BookmarkHTMLUtils.exportToFile(file);
|
||||
|
||||
// Remove the bookmarks, then restore the backup.
|
||||
PlacesUtils.bookmarks.removeItem(bm);
|
||||
yield BookmarkHTMLUtils.importFromFile(file, true);
|
||||
|
||||
do_log_info("Checking first level");
|
||||
let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root;
|
||||
let node = root.getChild(0);
|
||||
do_check_eq(node.uri, uri.spec);
|
||||
|
||||
root.containerOpen = false;
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
|
||||
});
|
@ -31,3 +31,4 @@ tail =
|
||||
[test_818593-store-backup-metadata.js]
|
||||
[test_818584-discard-duplicate-backups.js]
|
||||
[test_992901-backup-unsorted-hierarchy.js]
|
||||
[test_997030-bookmarks-html-encode.js]
|
||||
|
@ -34,6 +34,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkJSONUtils",
|
||||
"resource://gre/modules/BookmarkJSONUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkHTMLUtils",
|
||||
"resource://gre/modules/BookmarkHTMLUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
|
||||
"resource://gre/modules/PlacesBackups.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTransactions",
|
||||
|
Loading…
Reference in New Issue
Block a user