From 870d9c2e141d9fd494657f36c8c8e162eb446dff Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Fri, 21 Feb 2014 08:59:03 +0200 Subject: web client: fix path escaping problems --- web/path.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'web/path.js') diff --git a/web/path.js b/web/path.js index bb60c76..2373867 100644 --- a/web/path.js +++ b/web/path.js @@ -6,12 +6,34 @@ define(["underscore"], function(_) { function split(path) { var res = []; - while (path && path != "/") { - var comp = path.match(/^\/([^\\\/]|\\.)+/)[0]; - res.push(comp.substring(1)); - path = path.substring(comp.length); + var comp = ""; + var escaped; + + function merge(s) { + var n = Number(s); + if (s > "") res.push((escaped || isNaN) ? s : n); + } + + while (true) { + var m = path.match(/^([^\\\/]*)([\\\/])(.*)/); + if (!m) { + merge(comp + path); + return res; + } + + comp += m[1]; + if (m[2] == "\\") { + comp += m[3].substring(0, 1); + escaped = true; + path = m[3].substring(1); + } + else { + merge(comp); + comp = ""; + escaped = false; + path = m[3]; + } } - return res; } function escape(name) { -- cgit v1.2.3