Changed ..-replacement in examples

This commit is contained in:
eidheim 2014-08-29 19:02:34 +02:00
commit 3367b86f07
2 changed files with 4 additions and 12 deletions

View file

@ -83,14 +83,10 @@ int main() {
string path=request->path_match[1];
//Remove all but the last '.' (so we can't leave the web-directory)
size_t last_pos=path.rfind(".");
size_t current_pos=0;
//Replace all ".." with "." (so we can't leave the web-directory)
size_t pos;
while((pos=path.find('.', current_pos))!=string::npos && pos!=last_pos) {
current_pos=pos;
while((pos=path.find(".."))!=string::npos) {
path.erase(pos, 1);
last_pos--;
}
filename+=path;

View file

@ -83,14 +83,10 @@ int main() {
string path=request->path_match[1];
//Remove all but the last '.' (so we can't leave the web-directory)
size_t last_pos=path.rfind(".");
size_t current_pos=0;
//Replace all ".." with "." (so we can't leave the web-directory)
size_t pos;
while((pos=path.find('.', current_pos))!=string::npos && pos!=last_pos) {
current_pos=pos;
while((pos=path.find(".."))!=string::npos) {
path.erase(pos, 1);
last_pos--;
}
filename+=path;