Bug 783676 - Normalize "../../..". r=taras
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Fri, 24 Aug 2012 16:18:16 -0400
changeset 103344 f6ec0707def6e9348e563e84b2945fc74bdfc921
parent 103343 c97a5e95e1aeb2d1d2ba14d9b32935d917279c68
child 103345 e1700d9065d832c1fb179ff6fa6c37f0189d34b4
push id13945
push userryanvm@gmail.com
push dateFri, 24 Aug 2012 20:18:14 +0000
treeherdermozilla-inbound@b3c861bd1e2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstaras
bugs783676
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 783676 - Normalize "../../..". r=taras
toolkit/components/osfile/ospath_unix_back.jsm
toolkit/components/osfile/ospath_win_back.jsm
--- a/toolkit/components/osfile/ospath_unix_back.jsm
+++ b/toolkit/components/osfile/ospath_unix_back.jsm
@@ -96,23 +96,28 @@ if (typeof Components != "undefined") {
          case "..":
            if (stack.length == 0) {
              if (absolute) {
                throw new Error("Path is ill-formed: attempting to go past root");
              } else {
                stack.push("..");
              }
            } else {
-             stack.pop();
+             if (stack[stack.length - 1] == "..") {
+               stack.push("..");
+             } else {
+               stack.pop();
+             }
            }
            break;
          default:
            stack.push(v);
          }
        });
+       exports.OS.Shared.LOG("normalize", "stack", stack.toSource());
        let string = stack.join("/");
        return absolute ? "/" + string : string;
      },
      /**
       * Return the components of a path.
       * You should generally apply this function to a normalized path.
       *
       * @return {{
--- a/toolkit/components/osfile/ospath_win_back.jsm
+++ b/toolkit/components/osfile/ospath_win_back.jsm
@@ -192,17 +192,21 @@ if (typeof Components != "undefined") {
          case "..":
            if (stack.length == 0) {
              if (absolute) {
                throw new Error("Path is ill-formed: attempting to go past root");
              } else {
               stack.push("..");
              }
            } else {
-             stack.pop();
+             if (stack[stack.length - 1] == "..") {
+               stack.push("..");
+             } else {
+               stack.pop();
+             }
            }
            break;
          default:
            stack.push(v);
          }
        });
 
        // Put everything back together