Module: check_mk
Branch: master
Commit: 8075a7c2f33d9b9c5b6f96826fcdf6e399175b5a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8075a7c2f33d9b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue May 30 07:52:12 2017 +0200
4750 FIX Ensure uploaded icons are saved with their filename instead of paths
Uploaded icons may be saved with their full origin path as file name
(the location the file is stored on the client) with some browsers. This
could end up in paths like this:
C:\Users\Username\Documents\Icons\service.png will be stored in Check_MK like
~/local/share/check_mk/web/htdocs/images/icon/C:\\Users\\Username\\Documents\\Icons\\service.png
These files could not be used by the user after upload. These files are now
saved with their filename as expected.
Change-Id: If5c3d156056ef9eb2f4809f162a9bba4b1fdab34
---
.werks/4750 | 19 +++++++++++++++++++
web/htdocs/wato.py | 3 ++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/.werks/4750 b/.werks/4750
new file mode 100644
index 0000000..d6a1de7
--- /dev/null
+++ b/.werks/4750
@@ -0,0 +1,19 @@
+Title: Ensure uploaded icons are saved with their filename instead of paths
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1496123348
+
+Uploaded icons may be saved with their full origin path as file name
+(the location the file is stored on the client) with some browsers. This
+could end up in paths like this:
+
+C:\Users\Username\Documents\Icons\service.png will be stored in Check_MK like
+~/local/share/check_mk/web/htdocs/images/icon/C:\\Users\\Username\\Documents\\Icons\\service.png
+
+These files could not be used by the user after upload. These files are now
+saved with their filename as expected.
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 71b61b6..c23bb2b 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -15549,7 +15549,8 @@ def upload_icon(icon_info):
dest_dir = "%s/local/share/check_mk/web/htdocs/images/icons" %
cmk.paths.omd_root
make_nagios_directories(dest_dir)
try:
- im.save(dest_dir+'/'+icon_info['icon'][0], 'PNG',
pnginfo=meta)
+ file_name = os.path.basename(icon_info['icon'][0])
+ im.save(dest_dir+'/'+file_name, 'PNG', pnginfo=meta)
except IOError, e:
# Might happen with interlaced PNG files and PIL version < 1.1.7
raise MKUserError(None, _('Unable to upload icon: %s') % e)