From b96ea47f1fa5d987abe2849a95312d5460a31be0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 20 Nov 2017 12:09:17 +0100 Subject: [PATCH] strip tracking parameters when parsing urls --- www/assert/main.js | 11 +++++++++++ www/common/common-hash.js | 1 + 2 files changed, 12 insertions(+) diff --git a/www/assert/main.js b/www/assert/main.js index 3eb9e5892..09a5a8279 100644 --- a/www/assert/main.js +++ b/www/assert/main.js @@ -245,6 +245,17 @@ define([ hd.type === 'invite'); }, "test support for invite urls"); + assert(function (cb) { + var url = '/pad/?utm_campaign=new_comment&utm_medium=email&utm_source=thread_mailer#/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI/'; + var secret = Cryptpad.parsePadUrl(url); + + return cb(secret.hashData.version === 1 && + secret.hashData.mode === "edit" && + secret.hashData.channel === "3Ujt4F2Sjnjbis6CoYWpoQ" && + secret.hashData.key === "usn4+9CqVja8Q7RZOGTfRgqI" && + !secret.hashData.present); + }, "test support for ugly tracking query paramaters in url"); + assert(function (cb) { // TODO return cb(true); diff --git a/www/common/common-hash.js b/www/common/common-hash.js index 2aa2155bf..d53c6718d 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -114,6 +114,7 @@ Version 1 if (!href) { return ret; } if (href.slice(-1) !== '/') { href += '/'; } + href = href.replace(/\/\?[^#]+#/, '/#'); var idx;