Changed the acceptable mime type for uploaded xml files to be either text/xml or application/xml.

- Legacy-Id: 11280
This commit is contained in:
Henrik Levkowetz 2016-06-06 07:38:02 +00:00
parent 3eaef15fd5
commit 5395c85ed7
5 changed files with 7 additions and 7 deletions

View file

@ -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))

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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