瀏覽代碼

Fix unexpected 301 response - revert accidental change

commit 7e16295a57b4d2cbf4cae274912f32e4902b320c (5 Jun 2016)
accidentally reverted commit
commit 455cc3c0879268c94017f5f9a2110c6ac59d08fa
(commit d635fe8e0454c6a76271adf19c965803460f29c1)
merged with #317
bel 9 年之前
父節點
當前提交
1364711ee6
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/civetweb.c

+ 2 - 1
src/civetweb.c

@@ -10189,6 +10189,7 @@ handle_request(struct mg_connection *conn)
 		remove_double_dots_and_double_slashes((char *)ri->local_uri);
 
 		/* step 1. completed, the url is known now */
+		uri_len = (int)strlen(ri->local_uri);
 		DEBUG_TRACE("URL: %s", ri->local_uri);
 
 		/* 3. if this ip has limited speed, set it for this connection */
@@ -10451,7 +10452,7 @@ handle_request(struct mg_connection *conn)
 		}
 
 		/* 12. Directory uris should end with a slash */
-		if (file.is_directory && ri->local_uri[uri_len - 1] != '/') {
+		if (file.is_directory && (uri_len>0) && (ri->local_uri[uri_len - 1] != '/')) {
 			gmt_time_string(date, sizeof(date), &curtime);
 			mg_printf(conn,
 			          "HTTP/1.1 301 Moved Permanently\r\n"