From a4c81135d508411ee179d598bd40980428a06fd4 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Tue, 17 Jul 2012 14:20:30 +0200 Subject: [PATCH] Updates, guess what.., encoding #!@#*. --- src/_h5ai/js/inc/model/entry.js | 19 ++++++++++++++++--- src/_h5ai/js/inc/parser/apache-autoindex.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/_h5ai/js/inc/model/entry.js b/src/_h5ai/js/inc/model/entry.js index da6889b4..d86af656 100644 --- a/src/_h5ai/js/inc/model/entry.js +++ b/src/_h5ai/js/inc/model/entry.js @@ -3,6 +3,17 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty var doc = document, domain = doc.domain, + forceEncode = function (href) { + + return href + .replace(/'/g, '%27') + .replace(/\[/g, '%5B') + .replace(/\]/g, '%5D') + .replace(/\(/g, '%28') + .replace(/\)/g, '%29') + .replace(/\+/g, '%2B') + .replace(/\=/g, '%3D'); + }, location = (function () { var testpathname = '/a b', @@ -16,14 +27,14 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty location = a.href.replace(/.*:\/\/[^\/]*/, '').replace(/[^\/]*$/, ''); if (isDecoded) { - location = encodeURIComponent(location).replace(/%2F/ig, '/').replace(/'/g, '%27'); + location = encodeURIComponent(location).replace(/%2F/ig, '/'); } if (!location) { location = doc.location.href.replace(/.*:\/\/[^\/]*/, '').replace(/[^\/]*$/, ''); } - return location; + return forceEncode(location); }()), @@ -87,6 +98,8 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty Entry = function (absHref) { + absHref = forceEncode(absHref); + var split = splitPath(absHref); cache[absHref] = this; @@ -111,7 +124,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty get = function (absHref, time, size, status, isContentFetched) { - absHref = absHref || location; + absHref = forceEncode(absHref || location); var self = cache[absHref] || new Entry(absHref); diff --git a/src/_h5ai/js/inc/parser/apache-autoindex.js b/src/_h5ai/js/inc/parser/apache-autoindex.js index aec0bcc0..5123aeed 100644 --- a/src/_h5ai/js/inc/parser/apache-autoindex.js +++ b/src/_h5ai/js/inc/parser/apache-autoindex.js @@ -9,7 +9,7 @@ modulejs.define('parser/apache-autoindex', ['_', '$', 'core/settings', 'core/for time = format.parseDate($tds.eq(2).text(), 'DD-MMM-YYYY HH:mm'), size = format.parseSize($tds.eq(3).text()); - absHref = absHref + $a.attr('href').replace(/'/g, '%27').replace(/\+/g, '%2B').replace(/\=/g, '%3D'); + absHref = absHref + $a.attr('href'); return label === 'Parent Directory' ? null : Entry.get(absHref, time, size); },