You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to access a local pdf via the link [link to local pdf](local.pdf), the server returns the error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 10: invalid continuation byte
127.0.0.1 - - [20/Jun/2016 17:57:47] "GET /local.pdf HTTP/1.1" 500 -
[2016-06-20 17:58:44,374] ERROR in app: Exception on /local.pdf [GET]
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functionsrule.endpoint
File "/usr/lib/python3.5/site-packages/grip/app.py", line 163, in _render_page
text = self.reader.read(subpath)
File "/usr/lib/python3.5/site-packages/grip/readers.py", line 265, in read
return self._read_text(filename)
File "/usr/lib/python3.5/site-packages/grip/readers.py", line 146, in _read_text
return f.read()
File "/usr/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
Meanwhile, it serves local images properly. Is there any chance this could be fixed?
Thank you.
The text was updated successfully, but these errors were encountered:
At the moment, binary file detection is rather incomplete, so there's an opportunity for improvement. I wonder if something like this answer would be more appropriate for detecting binary files (and therefore, not trying to decode utf-8). I'll have to think more about it.
In the meantime, you could tweak that line locally in grip/grip/readers.py until an official more-general fix is released:
defis_binary(self, subpath=None):
""" Gets whether the specified subpath is a supported binary file. """ifsubpathandsubpath.endswith('.pdf'): # <-- addedreturnTrue# <-- addedmimetype=self.mimetype_for(subpath)
returnmimetypeisnotNoneandmimetype.startswith('image/')
When I try to access a local pdf via the link
[link to local pdf](local.pdf)
, the server returns the error:Meanwhile, it serves local images properly. Is there any chance this could be fixed?
Thank you.
The text was updated successfully, but these errors were encountered: