File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1635,7 +1635,7 @@ def test_upload_minutes_agenda(self):
16351635 q = PyQuery (r .content )
16361636 self .assertTrue (q ('form .has-error' ))
16371637
1638- test_file = StringIO ('this is some text for a test' )
1638+ test_file = StringIO (u'This is some text for a test, with the word \n virtual at the beginning of a line. ' )
16391639 test_file .name = "not_really.txt"
16401640 r = self .client .post (url ,dict (file = test_file ,apply_to_all = False ))
16411641 self .assertEqual (r .status_code , 302 )
Original file line number Diff line number Diff line change @@ -73,7 +73,13 @@ def validate_file_size(file):
7373
7474def validate_mime_type (file , valid ):
7575 file .open ()
76- mime_type , encoding = get_mime_type (file .read ())
76+ raw = file .read ()
77+ mime_type , encoding = get_mime_type (raw )
78+ # work around mis-identification of text where a line has 'virtual' as
79+ # the first word:
80+ if mime_type == 'text/x-c++' and re .search ('(?m)^virtual\s' , raw ):
81+ mod = raw .replace (str ('virtual' ), str (' virtual' ))
82+ mime_type , encoding = get_mime_type (mod )
7783 if not mime_type in valid :
7884 raise ValidationError ('Found content with unexpected mime type: %s. Expected one of %s.' %
7985 (mime_type , ', ' .join (valid ) ))
You can’t perform that action at this time.
0 commit comments