From d2573c1636303f490df641f8a1cdaa3c46616054 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 5 Jan 2022 14:27:11 +0200 Subject: [PATCH] Fix decoding UTF-8 filenames on unzipping. --- editor/editor_asset_installer.cpp | 4 ++-- editor/export_template_manager.cpp | 6 +++--- editor/project_manager.cpp | 6 +++--- platform/android/export/export_plugin.cpp | 4 ++-- platform/iphone/export/export_plugin.cpp | 2 +- platform/javascript/export/export_plugin.cpp | 2 +- platform/osx/export/export_plugin.cpp | 2 +- platform/uwp/export/export_plugin.cpp | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 4d6b2e27509d..1de67149c610 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -124,7 +124,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String name = fname; + String name = String::utf8(fname); files_sorted.insert(name); ret = unzGoToNextFile(pkg); @@ -303,7 +303,7 @@ void EditorAssetInstaller::ok_pressed() { char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String name = fname; + String name = String::utf8(fname); if (status_map.has(name) && status_map[name]->is_checked(0)) { String path = status_map[name]->get_metadata(0); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index f12a85138816..8c34609e9c98 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -396,7 +396,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file = fname; + String file = String::utf8(fname); if (file.ends_with("version.txt")) { Vector data; data.resize(info.uncompressed_size); @@ -457,7 +457,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file_path(String(fname).simplify_path()); + String file_path(String::utf8(fname).simplify_path()); String file = file_path.get_file(); @@ -698,7 +698,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ char fpath[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, nullptr, 0, nullptr, 0); - String path = fpath; + String path = String::utf8(fpath); String base_dir = path.get_base_dir(); if (!path.ends_with("/")) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 4b7380c83fae..08e0f7ae30e9 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -204,7 +204,7 @@ private: char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - if (String(fname).ends_with("project.godot")) { + if (String::utf8(fname).ends_with("project.godot")) { break; } @@ -524,7 +524,7 @@ private: char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String name = fname; + String name = String::utf8(fname); if (name.ends_with("project.godot")) { zip_root = name.substr(0, name.rfind("project.godot")); break; @@ -544,7 +544,7 @@ private: char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String path = fname; + String path = String::utf8(fname); if (path.is_empty() || path == zip_root || !zip_root.is_subsequence_of(path)) { // diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 8997d31e1fd7..cbecde787f22 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -2794,7 +2794,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref data; data.resize(info.uncompressed_size); @@ -2976,7 +2976,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref data; data.resize(info.compressed_size); diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp index 4a55ca1cbf07..0ad68086a7f5 100644 --- a/platform/iphone/export/export_plugin.cpp +++ b/platform/iphone/export/export_plugin.cpp @@ -1484,7 +1484,7 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p char fname[16384]; ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file = fname; + String file = String::utf8(fname); print_line("READ: " + file); Vector data; diff --git a/platform/javascript/export/export_plugin.cpp b/platform/javascript/export/export_plugin.cpp index 2134deebcb25..81ffae82bfcc 100644 --- a/platform/javascript/export/export_plugin.cpp +++ b/platform/javascript/export/export_plugin.cpp @@ -52,7 +52,7 @@ Error EditorExportPlatformJavaScript::_extract_template(const String &p_template char fname[16384]; unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file = fname; + String file = String::utf8(fname); // Skip service worker and offline page if not exporting pwa. if (!pwa && (file == "godot.service.worker.js" || file == "godot.offline.html")) { diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp index 786a8f38d82d..278c401e7f9e 100644 --- a/platform/osx/export/export_plugin.cpp +++ b/platform/osx/export/export_plugin.cpp @@ -571,7 +571,7 @@ Error EditorExportPlatformOSX::export_project(const Ref &p_p char fname[16384]; ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0); - String file = fname; + String file = String::utf8(fname); Vector data; data.resize(info.uncompressed_size); diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp index f1f100bdd39e..594495375a94 100644 --- a/platform/uwp/export/export_plugin.cpp +++ b/platform/uwp/export/export_plugin.cpp @@ -325,7 +325,7 @@ Error EditorExportPlatformUWP::export_project(const Ref &p_p char fname[16834]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16834, nullptr, 0, nullptr, 0); - String path = fname; + String path = String::utf8(fname); if (path.ends_with("/")) { // Ignore directories