Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #1764, use URIFixup to clean URLs. This cleans only the URL attac…
Browse files Browse the repository at this point in the history
…hed to the shot itself.
  • Loading branch information
ianb committed Oct 18, 2016
1 parent a9f6d78 commit b600a91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions addon/lib/fix-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { Cc, Ci } = require("chrome");
const newURI = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService)
.newURI;
const uriFixup = Cc["@mozilla.org/docshell/urifixup;1"]
.createInstance(Ci.nsIURIFixup);

module.exports = function (url) {
let uri = newURI(url, null, null);
try {
let cleaned = uriFixup.createExposableURI(uri);
return cleaned.spec;
} catch (e) {
e.extra = {originalURL: url};
require("./errors").unhandled(e);
console.warn("Could not convert URL:", url);
return url;
}
};
3 changes: 2 additions & 1 deletion addon/lib/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const { randomString } = require("./randomstring");
const { setTimeout, clearTimeout } = require("sdk/timers");
const shotstore = require("./shotstore");
const getCookies = require("./get-cookies");
const fixUrl = require("./fix-url");

let shouldShowTour = false; // eslint-disable-line no-unused-vars

Expand Down Expand Up @@ -94,7 +95,7 @@ const ShotContext = Class({
this.annotateForPage = annotateForPage === undefined ? annotateForPage : defaultAnnotateForPage;
this.id = ++ShotContext._idGen;
this.tab = tabs.activeTab;
this.tabUrl = this.tab.url;
this.tabUrl = fixUrl(this.tab.url);
let deviceIdInfo = getDeviceIdInfo();
if (! deviceIdInfo) {
throw new Error("Could not get device authentication information");
Expand Down

0 comments on commit b600a91

Please # to comment.