@@ -14,6 +14,7 @@ function normalizeStringWin32(path, allowAboveRoot) {
14
14
var lastSlash = - 1 ;
15
15
var dots = 0 ;
16
16
var code ;
17
+ var isAboveRoot = false ;
17
18
for ( var i = 0 ; i <= path . length ; ++ i ) {
18
19
if ( i < path . length )
19
20
code = path . charCodeAt ( i ) ;
@@ -25,7 +26,7 @@ function normalizeStringWin32(path, allowAboveRoot) {
25
26
if ( lastSlash === i - 1 || dots === 1 ) {
26
27
// NOOP
27
28
} else if ( lastSlash !== i - 1 && dots === 2 ) {
28
- if ( res . length < 2 ||
29
+ if ( res . length < 2 || ! isAboveRoot ||
29
30
res . charCodeAt ( res . length - 1 ) !== 46 /*.*/ ||
30
31
res . charCodeAt ( res . length - 2 ) !== 46 /*.*/ ) {
31
32
if ( res . length > 2 ) {
@@ -42,12 +43,14 @@ function normalizeStringWin32(path, allowAboveRoot) {
42
43
res = res . slice ( 0 , j ) ;
43
44
lastSlash = i ;
44
45
dots = 0 ;
46
+ isAboveRoot = false ;
45
47
continue ;
46
48
}
47
49
} else if ( res . length === 2 || res . length === 1 ) {
48
50
res = '' ;
49
51
lastSlash = i ;
50
52
dots = 0 ;
53
+ isAboveRoot = false ;
51
54
continue ;
52
55
}
53
56
}
@@ -56,12 +59,14 @@ function normalizeStringWin32(path, allowAboveRoot) {
56
59
res += '\\..' ;
57
60
else
58
61
res = '..' ;
62
+ isAboveRoot = true ;
59
63
}
60
64
} else {
61
65
if ( res . length > 0 )
62
66
res += '\\' + path . slice ( lastSlash + 1 , i ) ;
63
67
else
64
68
res = path . slice ( lastSlash + 1 , i ) ;
69
+ isAboveRoot = false ;
65
70
}
66
71
lastSlash = i ;
67
72
dots = 0 ;
@@ -80,6 +85,7 @@ function normalizeStringPosix(path, allowAboveRoot) {
80
85
var lastSlash = - 1 ;
81
86
var dots = 0 ;
82
87
var code ;
88
+ var isAboveRoot = false ;
83
89
for ( var i = 0 ; i <= path . length ; ++ i ) {
84
90
if ( i < path . length )
85
91
code = path . charCodeAt ( i ) ;
@@ -91,7 +97,7 @@ function normalizeStringPosix(path, allowAboveRoot) {
91
97
if ( lastSlash === i - 1 || dots === 1 ) {
92
98
// NOOP
93
99
} else if ( lastSlash !== i - 1 && dots === 2 ) {
94
- if ( res . length < 2 ||
100
+ if ( res . length < 2 || ! isAboveRoot ||
95
101
res . charCodeAt ( res . length - 1 ) !== 46 /*.*/ ||
96
102
res . charCodeAt ( res . length - 2 ) !== 46 /*.*/ ) {
97
103
if ( res . length > 2 ) {
@@ -108,12 +114,14 @@ function normalizeStringPosix(path, allowAboveRoot) {
108
114
res = res . slice ( 0 , j ) ;
109
115
lastSlash = i ;
110
116
dots = 0 ;
117
+ isAboveRoot = false ;
111
118
continue ;
112
119
}
113
120
} else if ( res . length === 2 || res . length === 1 ) {
114
121
res = '' ;
115
122
lastSlash = i ;
116
123
dots = 0 ;
124
+ isAboveRoot = false ;
117
125
continue ;
118
126
}
119
127
}
@@ -122,12 +130,14 @@ function normalizeStringPosix(path, allowAboveRoot) {
122
130
res += '/..' ;
123
131
else
124
132
res = '..' ;
133
+ isAboveRoot = true ;
125
134
}
126
135
} else {
127
136
if ( res . length > 0 )
128
137
res += '/' + path . slice ( lastSlash + 1 , i ) ;
129
138
else
130
139
res = path . slice ( lastSlash + 1 , i ) ;
140
+ isAboveRoot = false ;
131
141
}
132
142
lastSlash = i ;
133
143
dots = 0 ;
0 commit comments