From 5395c85ed7d3711569ae8472d2257587a1358a61 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Mon, 6 Jun 2016 07:38:02 +0000 Subject: [PATCH] Changed the acceptable mime type for uploaded xml files to be either text/xml or application/xml. - Legacy-Id: 11280 --- ietf/submit/parsers/base.py | 6 +++--- ietf/submit/parsers/pdf_parser.py | 2 +- ietf/submit/parsers/plain_parser.py | 2 +- ietf/submit/parsers/ps_parser.py | 2 +- ietf/submit/parsers/xml_parser.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ietf/submit/parsers/base.py b/ietf/submit/parsers/base.py index 7ad3fa002..2c4707b3a 100644 --- a/ietf/submit/parsers/base.py +++ b/ietf/submit/parsers/base.py @@ -41,7 +41,7 @@ class ParseInfo(object): class FileParser(object): ext = None - mimetype = None + mimetypes = [] def __init__(self, fd): self.fd = fd @@ -78,5 +78,5 @@ class FileParser(object): self.fd.file.seek(0) content = self.fd.file.read(4096) mimetype = magic.from_buffer(content, mime=True) - if not mimetype == self.mimetype: - self.parsed_info.add_error(u'Expected an %s file of type "%s", found one of type "%s"' % (self.ext.upper(), self.mimetype, mimetype)) + if not mimetype in self.mimetypes: + self.parsed_info.add_error(u'Expected an %s file of type "%s", found one of type "%s"' % (self.ext.upper(), '" or "'.join(self.mimetypes), mimetype)) diff --git a/ietf/submit/parsers/pdf_parser.py b/ietf/submit/parsers/pdf_parser.py index 6062920bd..56496bbd8 100644 --- a/ietf/submit/parsers/pdf_parser.py +++ b/ietf/submit/parsers/pdf_parser.py @@ -3,7 +3,7 @@ from ietf.submit.parsers.base import FileParser class PDFParser(FileParser): ext = 'pdf' - mimetype = 'application/pdf' + mimetypes = ['application/pdf', ] # If some error is found after this method invocation # no other file parsing is recommended diff --git a/ietf/submit/parsers/plain_parser.py b/ietf/submit/parsers/plain_parser.py index 62a64163f..daf948840 100644 --- a/ietf/submit/parsers/plain_parser.py +++ b/ietf/submit/parsers/plain_parser.py @@ -5,7 +5,7 @@ from ietf.submit.parsers.base import FileParser class PlainParser(FileParser): ext = 'txt' - mimetype = 'text/plain' + mimetypes = ['text/plain', ] def __init__(self, fd): super(PlainParser, self).__init__(fd) diff --git a/ietf/submit/parsers/ps_parser.py b/ietf/submit/parsers/ps_parser.py index 3597de05b..efb4b219e 100644 --- a/ietf/submit/parsers/ps_parser.py +++ b/ietf/submit/parsers/ps_parser.py @@ -3,7 +3,7 @@ from ietf.submit.parsers.base import FileParser class PSParser(FileParser): ext = 'ps' - mimetype = 'application/postscript' + mimetypes = ['application/postscript', ] # If some error is found after this method invocation # no other file parsing is recommended diff --git a/ietf/submit/parsers/xml_parser.py b/ietf/submit/parsers/xml_parser.py index a4beaecd2..674646e10 100644 --- a/ietf/submit/parsers/xml_parser.py +++ b/ietf/submit/parsers/xml_parser.py @@ -3,7 +3,7 @@ from ietf.submit.parsers.base import FileParser class XMLParser(FileParser): ext = 'xml' - mimetype = 'application/xml' + mimetypes = ['application/xml', 'text/xml', ] # If some error is found after this method invocation # no other file parsing is recommended