From 278d70f3ebbb1cc36d4007e1fc4ae9894e54fc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 11 Dec 2019 19:50:23 +0100 Subject: [PATCH] FIX: Add new content type for theme/component When uploading a theme/component, depending on the extension of the file and the OS/Browser being used, the content type might differ. This adds the "application/x-zip-compressed" content type that is being sent by most Browsers on latest Windows when uploading a .zip file. --- app/controllers/admin/themes_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb index 9db615e5199..d9bb61f6ada 100644 --- a/app/controllers/admin/themes_controller.rb +++ b/app/controllers/admin/themes_controller.rb @@ -51,6 +51,13 @@ class Admin::ThemesController < Admin::AdminController } end + THEME_CONTENT_TYPES ||= %w{ + application/gzip + application/x-gzip + application/x-zip-compressed + application/zip + } + def import @theme = nil if params[:theme] && params[:theme].content_type == "application/json" @@ -98,7 +105,7 @@ class Admin::ThemesController < Admin::AdminController rescue RemoteTheme::ImportError => e render_json_error e.message end - elsif params[:bundle] || (params[:theme] && ["application/x-gzip", "application/gzip", "application/zip"].include?(params[:theme].content_type)) + elsif params[:bundle] || (params[:theme] && THEME_CONTENT_TYPES.include?(params[:theme].content_type)) # params[:bundle] used by theme CLI. params[:theme] used by admin UI bundle = params[:bundle] || params[:theme] theme_id = params[:theme_id]