You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 17:36:07 +00:00
Add support for numeric XML entities to XMLParser
* Add support for decimal numeric entities to String::xml_unescape * Add more error checks to String::xml_unescape * Refactor XMLParser to use String::xml_unescape instead of an internal implementation
This commit is contained in:
committed by
Rémi Verschelde
parent
ed28ce53bf
commit
a28beb3048
@@ -1123,6 +1123,45 @@ bool test_35() {
|
||||
return state;
|
||||
}
|
||||
|
||||
bool test_36() {
|
||||
#define CHECK(X) \
|
||||
if (!(X)) { \
|
||||
OS::get_singleton()->print("\tFAIL at %s\n", #X); \
|
||||
return false; \
|
||||
} else { \
|
||||
OS::get_singleton()->print("\tPASS\n"); \
|
||||
}
|
||||
OS::get_singleton()->print("\n\nTest 36: xml unescape\n");
|
||||
// Named entities
|
||||
String input = ""&'<>";
|
||||
CHECK(input.xml_unescape() == "\"&\'<>");
|
||||
|
||||
// Numeric entities
|
||||
input = "AB";
|
||||
CHECK(input.xml_unescape() == "AB");
|
||||
|
||||
input = "�&x#0;More text";
|
||||
String result = input.xml_unescape();
|
||||
// Didn't put in a leading NUL and terminate the string
|
||||
CHECK(input.length() > 0);
|
||||
CHECK(input[0] != '\0');
|
||||
// Entity should be left as-is if invalid
|
||||
CHECK(input.xml_unescape() == input);
|
||||
|
||||
// Shouldn't consume without ending in a ';'
|
||||
input = "B";
|
||||
CHECK(input.xml_unescape() == input);
|
||||
input = "A";
|
||||
CHECK(input.xml_unescape() == input);
|
||||
|
||||
// Invalid characters should make the entity ignored
|
||||
input = "ASomeIrrelevantText;";
|
||||
CHECK(input.xml_unescape() == input);
|
||||
input = "BSomeIrrelevantText;";
|
||||
CHECK(input.xml_unescape() == input);
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef bool (*TestFunc)();
|
||||
|
||||
TestFunc test_funcs[] = {
|
||||
@@ -1162,6 +1201,7 @@ TestFunc test_funcs[] = {
|
||||
test_33,
|
||||
test_34,
|
||||
test_35,
|
||||
test_36,
|
||||
nullptr
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user