1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Allows parsing of invalid UTF-16 surrogates (can be encountered in Windows filenames) and some non-standard UTF-8 variants, makes Unicode parse errors more verbose.

This commit is contained in:
bruvzg
2022-07-05 15:18:29 +03:00
parent 28a3dee276
commit 0c5431644d
13 changed files with 321 additions and 198 deletions

View File

@@ -62,7 +62,8 @@ String cwd() {
}
String result;
if (result.parse_utf16(buffer.ptr())) {
result.parse_utf16(buffer.ptr());
if (result.is_empty()) {
return ".";
}
return result.simplify_path();
@@ -73,7 +74,7 @@ String cwd() {
}
String result;
if (result.parse_utf8(buffer)) {
if (result.parse_utf8(buffer) != OK) {
return ".";
}
@@ -114,7 +115,8 @@ String realpath(const String &p_path) {
::CloseHandle(hFile);
String result;
if (result.parse_utf16(buffer.ptr())) {
result.parse_utf16(buffer.ptr());
if (result.is_empty()) {
return p_path;
}
@@ -127,10 +129,10 @@ String realpath(const String &p_path) {
}
String result;
bool parse_ok = result.parse_utf8(resolved_path);
Error parse_ok = result.parse_utf8(resolved_path);
::free(resolved_path);
if (parse_ok) {
if (parse_ok != OK) {
return p_path;
}