@@ -35,6 +35,7 @@ function normalizeStringWin32(path, allowAboveRoot) {
35
35
var lastSlash = - 1 ;
36
36
var dots = 0 ;
37
37
var code ;
38
+ var isAboveRoot = false ;
38
39
for ( var i = 0 ; i <= path . length ; ++ i ) {
39
40
if ( i < path . length )
40
41
code = path . charCodeAt ( i ) ;
@@ -46,7 +47,7 @@ function normalizeStringWin32(path, allowAboveRoot) {
46
47
if ( lastSlash === i - 1 || dots === 1 ) {
47
48
// NOOP
48
49
} else if ( lastSlash !== i - 1 && dots === 2 ) {
49
- if ( res . length < 2 ||
50
+ if ( res . length < 2 || ! isAboveRoot ||
50
51
res . charCodeAt ( res . length - 1 ) !== 46 /*.*/ ||
51
52
res . charCodeAt ( res . length - 2 ) !== 46 /*.*/ ) {
52
53
if ( res . length > 2 ) {
@@ -63,12 +64,14 @@ function normalizeStringWin32(path, allowAboveRoot) {
63
64
res = res . slice ( 0 , j ) ;
64
65
lastSlash = i ;
65
66
dots = 0 ;
67
+ isAboveRoot = false ;
66
68
continue ;
67
69
}
68
70
} else if ( res . length === 2 || res . length === 1 ) {
69
71
res = '' ;
70
72
lastSlash = i ;
71
73
dots = 0 ;
74
+ isAboveRoot = false ;
72
75
continue ;
73
76
}
74
77
}
@@ -77,12 +80,14 @@ function normalizeStringWin32(path, allowAboveRoot) {
77
80
res += '\\..' ;
78
81
else
79
82
res = '..' ;
83
+ isAboveRoot = true ;
80
84
}
81
85
} else {
82
86
if ( res . length > 0 )
83
87
res += '\\' + path . slice ( lastSlash + 1 , i ) ;
84
88
else
85
89
res = path . slice ( lastSlash + 1 , i ) ;
90
+ isAboveRoot = false ;
86
91
}
87
92
lastSlash = i ;
88
93
dots = 0 ;
@@ -101,6 +106,7 @@ function normalizeStringPosix(path, allowAboveRoot) {
101
106
var lastSlash = - 1 ;
102
107
var dots = 0 ;
103
108
var code ;
109
+ var isAboveRoot = false ;
104
110
for ( var i = 0 ; i <= path . length ; ++ i ) {
105
111
if ( i < path . length )
106
112
code = path . charCodeAt ( i ) ;
@@ -112,7 +118,7 @@ function normalizeStringPosix(path, allowAboveRoot) {
112
118
if ( lastSlash === i - 1 || dots === 1 ) {
113
119
// NOOP
114
120
} else if ( lastSlash !== i - 1 && dots === 2 ) {
115
- if ( res . length < 2 ||
121
+ if ( res . length < 2 || ! isAboveRoot ||
116
122
res . charCodeAt ( res . length - 1 ) !== 46 /*.*/ ||
117
123
res . charCodeAt ( res . length - 2 ) !== 46 /*.*/ ) {
118
124
if ( res . length > 2 ) {
@@ -129,12 +135,14 @@ function normalizeStringPosix(path, allowAboveRoot) {
129
135
res = res . slice ( 0 , j ) ;
130
136
lastSlash = i ;
131
137
dots = 0 ;
138
+ isAboveRoot = false ;
132
139
continue ;
133
140
}
134
141
} else if ( res . length === 2 || res . length === 1 ) {
135
142
res = '' ;
136
143
lastSlash = i ;
137
144
dots = 0 ;
145
+ isAboveRoot = false ;
138
146
continue ;
139
147
}
140
148
}
@@ -143,12 +151,14 @@ function normalizeStringPosix(path, allowAboveRoot) {
143
151
res += '/..' ;
144
152
else
145
153
res = '..' ;
154
+ isAboveRoot = true ;
146
155
}
147
156
} else {
148
157
if ( res . length > 0 )
149
158
res += '/' + path . slice ( lastSlash + 1 , i ) ;
150
159
else
151
160
res = path . slice ( lastSlash + 1 , i ) ;
161
+ isAboveRoot = false ;
152
162
}
153
163
lastSlash = i ;
154
164
dots = 0 ;
0 commit comments