Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decoding UTF-8 filenames on unzipping. #56517

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions editor/editor_asset_installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions editor/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> data;
data.resize(info.uncompressed_size);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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("/")) {
Expand Down
6 changes: 3 additions & 3 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class ProjectDialog : public ConfirmationDialog {
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;
}

Expand Down Expand Up @@ -524,7 +524,7 @@ class ProjectDialog : public ConfirmationDialog {
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;
Expand All @@ -544,7 +544,7 @@ class ProjectDialog : public ConfirmationDialog {
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)) {
//
Expand Down
4 changes: 2 additions & 2 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2794,7 +2794,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP

bool skip = false;

String file = fname;
String file = String::utf8(fname);

Vector<uint8_t> data;
data.resize(info.uncompressed_size);
Expand Down Expand Up @@ -2976,7 +2976,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
char extra[16384];
ret = unzGetCurrentFileInfo(tmp_unaligned, &info, fname, 16384, extra, 16384 - ZIP_ALIGNMENT, nullptr, 0);

String file = fname;
String file = String::utf8(fname);

Vector<uint8_t> data;
data.resize(info.compressed_size);
Expand Down
2 changes: 1 addition & 1 deletion platform/iphone/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &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<uint8_t> data;
Expand Down
2 changes: 1 addition & 1 deletion platform/javascript/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion platform/osx/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &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<uint8_t> data;
data.resize(info.uncompressed_size);
Expand Down
2 changes: 1 addition & 1 deletion platform/uwp/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Error EditorExportPlatformUWP::export_project(const Ref<EditorExportPreset> &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
Expand Down