Kaynağa Gözat

core: fix parsing of verbatims strings

Follow-up to: eaedf25e4
Daniele Bartolini 7 ay önce
ebeveyn
işleme
516e67a089
2 değiştirilmiş dosya ile 8 ekleme ve 1 silme
  1. 1 1
      src/core/json/sjson.cpp
  2. 7 0
      src/core/unit_tests.cpp

+ 1 - 1
src/core/json/sjson.cpp

@@ -141,7 +141,7 @@ namespace sjson
 					return NULL;
 				}
 
-				while (strstr(json + 1, "\"\"\"") != NULL)
+				while (strncmp(json + 1, "\"\"\"", 3) == 0)
 					++json;
 
 				json += 3;

+ 7 - 0
src/core/unit_tests.cpp

@@ -1473,6 +1473,13 @@ static void test_sjson()
 		JsonObject obj(ta);
 		sjson::parse_object(obj, "{foo=[//]\n]}");
 	}
+	{
+		TempAllocator1024 ta;
+		JsonObject obj(ta);
+		sjson::parse_object(obj, "{foo=\"\"\"verbatim1\"\"\" bar=\"\"\"verbatim2\"\"\"}");
+		ENSURE(json_object::has(obj, "foo"));
+		ENSURE(json_object::has(obj, "bar"));
+	}
 	memory_globals::shutdown();
 }