diff --git a/.werks/668 b/.werks/668 new file mode 100644 index 0000000000000..0ddd17f395699 --- /dev/null +++ b/.werks/668 @@ -0,0 +1,8 @@ +Title: Allowing upload of files without loading the whole file into memory +Level: 1 +Component: multisite +Version: 1.2.5i1 +Date: 1392304629 +Class: fix + + diff --git a/ChangeLog b/ChangeLog index 5751d00811d42..ceb207d96d6bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -217,6 +217,7 @@ * 0273 FIX: Fixed exceptions when modifying / cloning views... * 0274 FIX: Fixed exception when view title or description was missing * 0278 FIX: Fixed bookmark icon images for non-english user languages... + * 0668 FIX: Allowing upload of files without loading the whole file into memory WATO: * 0308 Multisite can now set rotation view permissions for NagVis... diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py index c6985edfce2bb..b4802ae8915a8 100644 --- a/web/htdocs/htmllib.py +++ b/web/htdocs/htmllib.py @@ -1251,14 +1251,13 @@ def set_tree_states(self, tree, val): self.load_tree_states() self.treestates[tree] = val - def parse_field_storage(self, fields): + def parse_field_storage(self, fields, handle_uploads_as_file_obj = False): self.vars = {} self.listvars = {} # for variables with more than one occurrance self.uploads = {} for field in fields.list: varname = field.name - value = field.value # To prevent variours injections, we only allow a defined set # of characters to be used in variables @@ -1267,19 +1266,23 @@ def parse_field_storage(self, fields): # put uploaded file infos into separate storage if field.filename is not None: - self.uploads[varname] = (field.filename, field.type, field.value) + if handle_uploads_as_file_obj: + value = field.file + else: + value = field.value + self.uploads[varname] = (field.filename, field.type, value) else: # normal variable # Multiple occurrance of a variable? Store in extra list dict if varname in self.vars: if varname in self.listvars: - self.listvars[varname].append(value) + self.listvars[varname].append(field.value) else: - self.listvars[varname] = [ self.vars[varname], value ] + self.listvars[varname] = [ self.vars[varname], field.value ] # In the single-value-store the last occurrance of a variable # has precedence. That makes appending variables to the current # URL simpler. - self.vars[varname] = value + self.vars[varname] = field.value def uploaded_file(self, varname, default = None): return self.uploads.get(varname, default)