sehmaschine / django-grappelli

A jazzy skin for the Django Admin-Interface (official repository).
http://www.grappelliproject.com
Other
3.77k stars 657 forks source link

Wrong utf-8 characters in tiny_mce static files #988

Closed ricard33 closed 2 years ago

ricard33 commented 2 years ago

After upgrading django-grappelli to version 3.0.1, the command python manage.py collectstatic fails to decode two files from tiny_mce :

Error is:

[...]
  File "/Users/ricard/.env/loc/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 427, in post_process
    yield from super().post_process(*args, **kwargs)
  File "/Users/ricard/.env/loc/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 247, in post_process
    for name, hashed_name, processed, _ in self._post_process(paths, adjustable_paths, hashed_files):
  File "/Users/ricard/.env/loc/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 307, in _post_process
    content = original_file.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 4560: invalid start byte

Opening editor_plugin.jsand editor_plugin_src.js, one can see some invalid characters (respective positions are 2819 and 4560).

Kiougar commented 2 years ago

I have the same issue after upgrading to Django 4 and that's because the HashedFilesMixin now reads the contents of *.js files so that it can replace the paths of JavaScript source maps.

As a temporary workaround, I added my own editor_plugin.js and editor_plugin_src.js static files that are copies of the original with the invalid characters removed.

@sehmaschine I noticed you initially removed tinymce but then you added it back in. Any reason why we cannot remove it?

sehmaschine commented 2 years ago

@Kiougar we could remove it. But I check the tinymce-website again (after I removed it) and it seems that you need to register for the free version (which is a bit strange IMO). So I thought it´s better to keep it for now. Besides, we did not communicate the depreciation correctly.

Kiougar commented 2 years ago

that you need to register for the free version

What does that mean exactly?

So I thought it´s better to keep it for now. Besides, we did not communicate the depreciation correctly.

Yeah, makes sense - it's going to be a pain though for people that use the ManifestStaticFilesStorage since it simply won't work unless we manually edit the files.

Should I create a PR that changes the editor_plugin.js and editor_plugin_src.js files?

sehmaschine commented 2 years ago

A PR is appreciated

Kiougar commented 2 years ago

PR ready - @sehmaschine can you please check when you get a chance?

sehmaschine commented 2 years ago

Thanks. I'll check the PR in the next couple of days.