Skip to content

Commit

Permalink
Merge branch 'release-1.13.0b2'
Browse files Browse the repository at this point in the history
* release-1.13.0b2:
  Update version info.
  capture: new option to serialize filename
  capture: remove forceUtf8 from the detail dialog
  capture: fix incomplete finalization of a capture without file downloads
  capture: fix missing favicon in some cases
  core: centralize sbCommonUtils.readMetaRefresh()
  core: centralize sbCommonUtils.escapeHTMLComment()
  core: sort sbCommonUtils.resolveURL()
  output: fix wrong path of bookmarks in the search result
  capture: fix download() for a special case
  capture: code optimization (with minor semantic change)
  • Loading branch information
danny0838 committed Jul 8, 2016
2 parents 80ba777 + 7164fd6 commit 9f60e7a
Show file tree
Hide file tree
Showing 34 changed files with 199 additions and 116 deletions.
16 changes: 5 additions & 11 deletions chrome/content/scrapbook/combine.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,21 +413,15 @@ var sbPageCombiner = {
},

getCiteHTML: function(aType) {
// add a thin space between "--" in the comment to prevent exploits
var src = '\n<!--' + sbCombineService.postfix.replace(/--/g, "- -") + '-->\n';
var src = '\n<!--' + sbCommonUtils.escapeHTMLComment(sbCombineService.postfix) + '-->\n';
var title = sbDataSource.getProperty(sbCombineService.curRes, "title");
var linkURL = "";
switch ( aType ) {
case "file":
var htmlFile = sbCommonUtils.getContentDir(sbCombineService.curID);
htmlFile.append("index.html");
if (sbCommonUtils.readFile(htmlFile).match(/\s*content="\d+;URL=([^"]+)"/i)) {
var file = sbCommonUtils.getContentDir(sbCombineService.curID); file.append("index.html");
var relURL = sbCommonUtils.convertToUnicode(RegExp.$1, "UTF-8");
var URI1 = sbCommonUtils.convertFilePathToURL(file.path);
var URI2 = sbCommonUtils.resolveURL(URI1, relURL);
var file2 = sbCommonUtils.convertURLToFile(URI2);
linkURL = sbCommonUtils.convertFilePathToURL(file2.path);
var htmlFile = sbCommonUtils.getContentDir(sbCombineService.curID); htmlFile.append("index.html");
var targetFile = sbCommonUtils.readMetaRefresh(htmlFile);
if (targetFile) {
linkURL = sbCommonUtils.convertFilePathToURL(targetFile.path);
}
break;
case "note":
Expand Down
3 changes: 0 additions & 3 deletions chrome/content/scrapbook/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var sbCaptureOptions = {
document.getElementById("sbDetailOptionStyles").checked = sbCommonUtils.getPref("capture.default.styles", true);
document.getElementById("sbDetailOptionScript").checked = sbCommonUtils.getPref("capture.default.script", false);
document.getElementById("sbDetailOptionAsHtml").checked = sbCommonUtils.getPref("capture.default.asHtml", false);
document.getElementById("sbDetailOptionForceUtf8").checked = sbCommonUtils.getPref("capture.default.forceUtf8", true);
document.getElementById("sbDetailOptionRewriteStyles").checked = sbCommonUtils.getPref("capture.default.rewriteStyles", true);
document.getElementById("sbDetailOptionKeepLink").checked = sbCommonUtils.getPref("capture.default.keepLink", false);
document.getElementById("sbDetailOptionSaveDataURI").checked = sbCommonUtils.getPref("capture.default.saveDataURI", false);
Expand Down Expand Up @@ -88,7 +87,6 @@ var sbCaptureOptions = {
this.param.option["styles"] = document.getElementById("sbDetailOptionStyles").checked;
this.param.option["script"] = document.getElementById("sbDetailOptionScript").checked;
this.param.option["asHtml"] = document.getElementById("sbDetailOptionAsHtml").checked;
this.param.option["forceUtf8"] = document.getElementById("sbDetailOptionForceUtf8").checked;
this.param.option["rewriteStyles"] = document.getElementById("sbDetailOptionRewriteStyles").checked;
this.param.option["keepLink"] = document.getElementById("sbDetailOptionKeepLink").checked;
this.param.option["saveDataURI"] = document.getElementById("sbDetailOptionSaveDataURI").checked;
Expand All @@ -105,7 +103,6 @@ var sbCaptureOptions = {
sbCommonUtils.setPref("capture.default.styles", this.param.option["styles"]);
sbCommonUtils.setPref("capture.default.script", this.param.option["script"]);
sbCommonUtils.setPref("capture.default.asHtml", this.param.option["asHtml"]);
sbCommonUtils.setPref("capture.default.forceUtf8", this.param.option["forceUtf8"]);
sbCommonUtils.setPref("capture.default.rewriteStyles", this.param.option["rewriteStyles"]);
sbCommonUtils.setPref("capture.default.keepLink", this.param.option["keepLink"]);
sbCommonUtils.setPref("capture.default.saveDataURI", this.param.option["saveDataURI"]);
Expand Down
1 change: 0 additions & 1 deletion chrome/content/scrapbook/detail.xul
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<checkbox id="sbDetailOptionSaveDataURI" label="&sb.detail.option.saveDataURI;" />
<checkbox id="sbDetailOptionKeepLink" label="&sb.detail.option.keepLink;" />
<checkbox id="sbDetailOptionRewriteStyles" label="&sb.detail.option.rewriteStyles;" />
<checkbox id="sbDetailOptionForceUtf8" label="&sb.detail.option.forceUtf8;" />
<checkbox id="sbDetailOptionAsHtml" label="&sb.detail.option.asHtml;" />
</groupbox>
<groupbox group="capture-options" style="margin-top:8px;">
Expand Down
30 changes: 11 additions & 19 deletions chrome/content/scrapbook/fulltext.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,14 @@ var sbCacheService = {
if (!file.exists()) break;
// if the file is rather small, check for a possible meta refresh to the real html file
if (file.fileSize <= 512) {
// use a simple heuristic match for meta tag refresh
// should be enough for most cases
if (sbCommonUtils.readFile(file).match(/\s*content="\d+;URL=([^"]+)"/i)) {
var redirectFile = sbCommonUtils.readMetaRefresh(file);
if (redirectFile) {
// found meta refresh, check further
var relURL = sbCommonUtils.convertToUnicode(RegExp.$1, "UTF-8");
var URI1 = sbCommonUtils.convertFilePathToURL(file.path);
var URI2 = sbCommonUtils.resolveURL(URI1, relURL);
var file2 = sbCommonUtils.convertURLToFile(URI2);
if (!file2.exists()) break;
var mime = sbCommonUtils.getFileMime(file2);
if (!redirectFile.exists()) break;
var mime = sbCommonUtils.getFileMime(redirectFile);
if ( !mime || ["text/html", "application/xhtml+xml"].indexOf(mime) < 0 ) break;
var basePathCut = dir.path.length + 1;
sbCacheService.inspectFile(file2, file2.path.substring(basePathCut).replace(/\\/g, "/"), "html");
sbCacheService.inspectFile(redirectFile, redirectFile.path.substring(basePathCut).replace(/\\/g, "/"), "html");
break;
}
}
Expand Down Expand Up @@ -402,19 +397,16 @@ var sbCacheService = {
if (!file.exists()) break;
// use a simple heuristic match for meta tag refresh generated by ScrapBook
// other arbitrary is not guaranteed
if (sbCommonUtils.readFile(file).match(/\s*content="\d+;URL=([^"]+)"/i)) {
var relURL = sbCommonUtils.convertToUnicode(RegExp.$1, "UTF-8");
var URI1 = sbCommonUtils.convertFilePathToURL(file.path);
var URI2 = sbCommonUtils.resolveURL(URI1, relURL);
var file2 = sbCommonUtils.convertURLToFile(URI2);
if (!file2.exists()) break;
var mime = sbCommonUtils.getFileMime(file2);
var redirectFile = sbCommonUtils.readMetaRefresh(file);
if (redirectFile && redirectFile.exists()) {
var mime = sbCommonUtils.getFileMime(redirectFile);
var basePathCut = dir.path.length + 1;
if ( mime && mime.indexOf("text/") == 0 ) {
sbCacheService.inspectFile(file2, file2.path.substring(basePathCut).replace(/\\/g, "/"), "text");
sbCacheService.inspectFile(redirectFile, redirectFile.path.substring(basePathCut).replace(/\\/g, "/"), "text");
} else {
sbCacheService.inspectFile(file2, file2.path.substring(basePathCut).replace(/\\/g, "/"), "none");
sbCacheService.inspectFile(redirectFile, redirectFile.path.substring(basePathCut).replace(/\\/g, "/"), "none");
}
break;
}
break;
case "bookmark":
Expand Down
17 changes: 9 additions & 8 deletions chrome/content/scrapbook/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,26 +740,26 @@ var sbOutputService = {
+ ' var item = data.item;\n'
+ ' var wrapper = document.getElementById("result");\n'
+ ' var result = document.createElement("LI");\n'
+ ' var href = (item.type == "bookmark") ?\n'
+ ' item.source:\n'
+ ' "data/" + item.id + "/" + cache.path.replace(/[^\\/]+/g, function(m){return encodeURIComponent(m);});\n'
+ ' var subpath = "data/" + item.id + "/" + cache.path.replace(/[^\\/]+/g, function(m){return encodeURIComponent(m);});\n'
+ ' var bullet = this.config["list_bullet"] + " ";\n'
+ ' var text = item.type == "bookmark" ?\n'
+ ' bullet + item.title:\n'
+ ' item.title + ((cache.path != "index.html") ? (" (" + cache.path + ")") : "");\n'
+ ' if (item.type != "bookmark") {\n'
+ ' var fhref = scrapbook.path + "/" + "tree/frame.html#../" + href;\n'
+ ' var href = scrapbook.path + "/" + "tree/frame.html#../" + subpath;\n'
+ ' var link = document.createElement("A");\n'
+ ' link.setAttribute("href", fhref);\n'
+ ' link.setAttribute("href", href);\n'
+ ' link.setAttribute("target", "_blank");\n'
+ ' link.setAttribute("class", "bookmark");\n'
+ ' link.setAttribute("title", "View In Frame");\n'
+ ' link.appendChild(document.createTextNode(bullet));\n'
+ ' result.appendChild(link);\n'
+ ' }\n'
+ ' var href = (item.type == "bookmark") ? item.source : scrapbook.path + "/" + subpath;\n'
+ ' var target = (item.type == "bookmark") ? "_blank" : "main";\n'
+ ' var link = document.createElement("A");\n'
+ ' link.setAttribute("href", scrapbook.path + "/" + href);\n'
+ ' link.setAttribute("target", "main");\n'
+ ' link.setAttribute("href", href);\n'
+ ' link.setAttribute("target", target);\n'
+ ' link.setAttribute("class", item.type);\n'
+ ' link.setAttribute("title", item.title);\n'
+ ' link.appendChild(document.createTextNode(text));\n'
Expand Down Expand Up @@ -822,7 +822,8 @@ var sbOutputService = {
+ '</form>\n'
+ '<div><ul id="result"></ul></div>\n'
+ '</body>\n'
+ '</html>\n';
+ '</html>\n'
+ '';
return HTML;
}
};
Expand Down
Loading

0 comments on commit 9f60e7a

Please sign in to comment.