Changed ..-replacement in examples
This commit is contained in:
parent
b174ad5232
commit
3367b86f07
2 changed files with 4 additions and 12 deletions
|
|
@ -83,14 +83,10 @@ int main() {
|
||||||
|
|
||||||
string path=request->path_match[1];
|
string path=request->path_match[1];
|
||||||
|
|
||||||
//Remove all but the last '.' (so we can't leave the web-directory)
|
//Replace all ".." with "." (so we can't leave the web-directory)
|
||||||
size_t last_pos=path.rfind(".");
|
|
||||||
size_t current_pos=0;
|
|
||||||
size_t pos;
|
size_t pos;
|
||||||
while((pos=path.find('.', current_pos))!=string::npos && pos!=last_pos) {
|
while((pos=path.find(".."))!=string::npos) {
|
||||||
current_pos=pos;
|
|
||||||
path.erase(pos, 1);
|
path.erase(pos, 1);
|
||||||
last_pos--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filename+=path;
|
filename+=path;
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,10 @@ int main() {
|
||||||
|
|
||||||
string path=request->path_match[1];
|
string path=request->path_match[1];
|
||||||
|
|
||||||
//Remove all but the last '.' (so we can't leave the web-directory)
|
//Replace all ".." with "." (so we can't leave the web-directory)
|
||||||
size_t last_pos=path.rfind(".");
|
|
||||||
size_t current_pos=0;
|
|
||||||
size_t pos;
|
size_t pos;
|
||||||
while((pos=path.find('.', current_pos))!=string::npos && pos!=last_pos) {
|
while((pos=path.find(".."))!=string::npos) {
|
||||||
current_pos=pos;
|
|
||||||
path.erase(pos, 1);
|
path.erase(pos, 1);
|
||||||
last_pos--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filename+=path;
|
filename+=path;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue