django-cms / djangocms-text-ckeditor

Text Plugin for django CMS using CKEditor 4
https://www.django-cms.org/en/repositories-plugins/
BSD 3-Clause "New" or "Revised" License
167 stars 185 forks source link

image upload: image_type not detected #83

Closed robertolopezlopez closed 8 years ago

robertolopezlopez commented 10 years ago

Hi.

I am trying to drag and drop an image, but there's an IndexError in djangocms_text_ckeditor/html.py. It seems mime_type always = u'', so mime_type.split("/")[1] gives an error.

It happens both in localhost, with development server, and production, with apache and wsgi.

Environment:

Request Method: POST Request URL: http://127.0.0.1:8000/en/admin/cms/page/1/edit-plugin/172/

Django Version: 1.5.4 Python Version: 2.7.3 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.sitemaps', 'modeltranslation', 'djangocms_text_ckeditor', 'cms', 'mptt', 'menus', 'south', 'sekizai', 'cms.plugins.file', 'cms.plugins.link', 'cms.plugins.video', 'cmsplugin_news', 'reversion', 'django_extensions', 'guardian', 'country_dialcode', 'ckeditor', 'unicms', 'home', 'staff', 'research_area', 'project', 'department', 'contact', 'about', 'group', 'research_area', 'products_activities', 'topics', 'news') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'cms.middleware.page.CurrentPageMiddleware', 'cms.middleware.user.CurrentUserMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware', 'cms.middleware.language.LanguageCookieMiddleware')

Traceback: File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  2. response = view_func(request, _args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  3. response = view_func(request, _args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  4. return view(request, _args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/views/decorators/clickjacking.py" in wrapped_view
  5. resp = view_func(_args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/reversion/revisions.py" in do_revision_context
  6. return func(_args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/cms/admin/pageadmin.py" in edit_plugin
  7. response = plugin_admin.add_view(request) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  8. return bound_func(_args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  9. response = view_func(request, _args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  10. return func(self, _args2, *_kwargs2) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
  11. return func(_args, *_kwargs) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
  12. self.save_model(request, new_object, form, False) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/djangocms_text_ckeditor/cms_plugins.py" in save_model
  13. super(TextPlugin, self).save_model(request, obj, form, change) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/cms/plugin_base.py" in save_model
  14. return super(CMSPluginBase, self).save_model(request, obj, form, change) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_model
  15. obj.save() File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/djangocms_text_ckeditor/models.py" in save
  16. body = extract_images(body, self) File "/home/roberto/.virtualenvs/ve_master/local/lib/python2.7/site-packages/djangocms_text_ckeditor/html.py" in extract_images
  17. image_type = mime_type.split("/")[1]

Exception Type: IndexError at /en/admin/cms/page/1/edit-plugin/172/ Exception Value: list index out of range

I am using the following environment in my local machine:

Django - 1.5.4 - active PIL - 1.1.7 - active Pillow - 2.2.1 - active Pygments - 1.6 - active Python - 2.7.3 - active development (/usr/lib/python2.7/lib-dynload) South - 0.8.2 - active argparse - 1.2.1 - active development (/usr/lib/python2.7) bpython - 0.12 - active cmsplugin-news - 0.4.2 - active django-ckeditor - 4.0.2 - active django-classy-tags - 0.4 - active django-cms - 2.4.2 - active django-country-dialcode - 0.4.8 - active django-extensions - 1.2.2 - active django-guardian - 1.1.1 - active django-modeltranslation - 0.6.1 - active django-mptt - 0.5.2 - active django-reusableapps - 0.1.1 - active django-reversion - 1.7.1 - active django-sekizai - 0.7 - active djangocms-text-ckeditor - 1.0.10 - active html5lib - 1.0b3 - active pip - 1.2.1 - active psycopg2 - 2.5.1 - active python-ldap - 2.4.13 - active python-magic - 0.4.6 - active pytz - 2013.7 - active setuptools - 0.6c11 - active six - 1.4.1 - active switch2bill-common - 2.8.1 - active wsgiref - 0.1.2 - active development (/usr/lib/python2.7) yolk - 0.4.3 - active

robertolopezlopez commented 10 years ago

It seems a duplicate of https://github.com/divio/djangocms-text-ckeditor/issues/79