inveniosoftware / invenio-app-rdm

Turn-key research data management platform.
https://inveniordm.docs.cern.ch
MIT License
100 stars 144 forks source link

txt previewer issues #1864

Closed tmorrell closed 1 year ago

tmorrell commented 2 years ago

Package version (if known): v9.1

Describe the bugs

Steps to Reproduce

  1. Create a record with the attached license file: LICENSE_TCCON.txt
  2. Look at previewer
  3. See error

Trackback is:

Traceback (most recent call last):
/lib/python3.8/site-packages/flask/app.py", line 2095, in __call__
     return self.wsgi_app(environ, start_response)
/lib/python3.8/site-packages/werkzeug/middleware/proxy_fix.py", line 187, in __call__
   return self.app(environ, start_response)
/lib/python3.8/site-packages/flask/app.py", line 2080, in wsgi_app
  response = self.handle_exception(e)
/lib/python3.8/site-packages/flask/app.py", line 2077, in wsgi_app
   response = self.full_dispatch_request()
/lib/python3.8/site-packages/flask/app.py", line 1525, in full_dispatch_request
     rv = self.handle_user_exception(e)
/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request
   rv = self.dispatch_request()
/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request
     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
/lib/python3.8/site-packages/invenio_app_rdm/records_ui/views/decorators.py", line 79, in view
   return f(**kwargs)
/lib/python3.8/site-packages/invenio_app_rdm/records_ui/views/decorators.py", line 127, in view
     return f(**kwargs)
/lib/python3.8/site-packages/invenio_app_rdm/records_ui/views/decorators.py", line 189, in view
     return f(**kwargs)
/lib/python3.8/site-packages/invenio_app_rdm/records_ui/views/records.py", line 155, in record_file_preview
     return plugin.preview(fileobj)
/lib/python3.8/site-packages/invenio_previewer/extensions/txt.py", line 38, in preview
    content=render(file),
/lib/python3.8/site-packages/invenio_previewer/extensions/txt.py", line 23, in render
    return fp.read().decode(encoding)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1291: ordinal not in range(128)

Expected behavior

File should preview with utf-8 encoding

Screenshots (if applicable)

Screen Shot 2022-09-07 at 1 57 20 PM

Additional context

fenekku commented 1 year ago

Yep.

We also found out that the previewer doesn't scroll horizontally, so txt files with long lines don't preview nicely. I am adding this to your ticket.

github-actions[bot] commented 1 year ago

This issue was automatically marked as stale.

github-actions[bot] commented 1 year ago

This issue was automatically marked as stale.

github-actions[bot] commented 1 year ago

This issue was automatically marked as stale.

github-actions[bot] commented 1 year ago

This issue was automatically marked as stale.