소스 검색

fixes SER-322:
- parser sticks in an endless loop when the terminating
quote mark is missing in a substring: @hf_value["Contact].uri
- quote mark can be escaped: @hf_value[\"Contact\"].uri

Miklos Tirpak 18 년 전
부모
커밋
b3d26eadf9
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      select.c

+ 7 - 1
select.c

@@ -92,11 +92,17 @@ int w_parse_select(char**p, select_t* sel)
 		sel->n++;
 		if (*(*p)=='[') {
 			(*p)++; 
+			if (*(*p)=='\\') (*p)++;
 			if (*(*p)=='"') {
 				(*p)++;	
 				name.s=(*p);
-				while (*(*p)!='"') (*p)++;
+				while ((*(*p)!='\0') && (*(*p)!='"')) (*p)++;
+				if (*(*p)!='"') {
+					ERR("parse_select: end of string is missing\n");
+					goto error;
+				}
 				name.len=(*p)-name.s;
+				if (*((*p)-1)=='\\') name.len--;
 				(*p)++;
 				if (*(*p)!=']') {
 					ERR("parse_select: invalid string index, no closing ]\n");