Skip to content

A platform for community discussion. Free, open, simple.

FIX: Support application/gzip theme imports, and improve error message

David Taylor77d26b9df602
diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb
index 4ee50cfba49..15027da7ff4 100644
--- a/app/controllers/admin/themes_controller.rb
+++ b/app/controllers/admin/themes_controller.rb
@@ -84,7 +84,7 @@ class Admin::ThemesController < Admin::AdminController
rescue RemoteTheme::ImportError => e
render_json_error e.message
end
- elsif params[:bundle] || params[:theme] && params[:theme].content_type == "application/x-gzip"
+ elsif params[:bundle] || params[:theme] && ["application/x-gzip", "application/gzip"].include?(params[:theme].content_type)
# params[:bundle] used by theme CLI. params[:theme] used by admin UI
bundle = params[:bundle] || params[:theme]
begin
@@ -95,7 +95,7 @@ class Admin::ThemesController < Admin::AdminController
render_json_error e.message
end
else
- render_json_error status: :unprocessable_entity
+ render_json_error I18n.t("themes.import_error.unknown_file_type"), status: :unprocessable_entity
end
end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 348dc68b7c1..ddea713c1c6 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -80,6 +80,7 @@ en:
about_json_values: "about.json contains invalid values: %{errors}"
git: "Error cloning git repository, access is denied or repository is not found"
unpack_failed: "Failed to unpack file"
+ unknown_file_type: "The file you uploaded does not appear to be a valid Discourse theme."
errors:
component_no_user_selectable: "Theme components can't be user-selectable"
component_no_default: "Theme components can't be default theme"