Przeglądaj źródła

URI check in "remove_dot_segments": replace all // by /

bel2125 5 lat temu
rodzic
commit
6fad4ba8d7
1 zmienionych plików z 19 dodań i 0 usunięć
  1. 19 0
      src/civetweb.c

+ 19 - 0
src/civetweb.c

@@ -7951,9 +7951,13 @@ remove_dot_segments(char *inout)
 	/* For Windows, the files/folders "x" and "x." (with a dot but without
 	 * extension) are identical. Replace all "./" by "/" and remove a "." at the
 	 * end.
+	 * Also replace all "//" by "/".
+	 * Repeat until there is no "./" or "//" anymore.
 	 */
 	do {
 		replaced = 0;
+
+		/* replace ./ by / */
 		out_end = out_begin;
 		while (*out_end) {
 			if ((*out_end == '.')
@@ -7967,6 +7971,21 @@ remove_dot_segments(char *inout)
 			}
 			out_end++;
 		}
+
+		/* replace ./ by / */
+		out_end = out_begin;
+		while (*out_end) {
+			if ((out_end[0] == '/') && (out_end[1] == '/')) {
+				char *c = out_end;
+				while (*c) {
+					c[0] = c[1];
+					c++;
+				}
+				replaced = 1;
+			}
+			out_end++;
+		}
+
 	} while (replaced);
 
 	/* Free temporary copies */