Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Error when sharing Unicode named file #1

Open
nerom86 opened this issue Jul 10, 2011 · 0 comments
Open

Error when sharing Unicode named file #1

nerom86 opened this issue Jul 10, 2011 · 0 comments

Comments

@nerom86
Copy link

nerom86 commented Jul 10, 2011

example: привет.zip

UnicodeEncodeError at /files/download/ZmI4ZDc3Mj
'ascii' codec can't encode characters in position 21-27: ordinal not in range(128), HTTP response headers must be in US-ASCII format
Request Method: GET
Request URL: http://77.4.132.153:8888/files/download/ZmI4ZDc3Mj
Django Version: 1.3
Exception Type: UnicodeEncodeError
Exception Value:
'ascii' codec can't encode characters in position 21-27: ordinal not in range(128), HTTP response headers must be in US-ASCII format
Exception Location: /usr/lib/python2.7/site-packages/django/http/init.py in _convert_to_ascii, line 517
Python Executable: /usr/bin/python2
Python Version: 2.7.2
Python Path:
['/opt/PlugUI',
'/usr/lib/python27.zip',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/lib/python2.7/site-packages',
'/usr/lib/python2.7/site-packages/PIL',
'/opt']
Server time: Sun, 10 Jul 2011 22:22:00 +0200
Unicode error hint

The string that could not be encoded/decoded was: name=Легенды русс
Traceback Switch to copy-and-paste view

/usr/lib/python2.7/site-packages/django/core/handlers/base.py in get_response
response = callback(request, _callback_args, *_callback_kwargs) ...
▶ Local vars
/usr/lib/python2.7/site-packages/django/views/decorators/http.py in inner
response = func(request, _args, *_kwargs) ...
▶ Local vars
/opt/PlugUI/files/views.py in downloadshare
response = privateapi.core.streamfile(path,"download") ...
▶ Local vars
/opt/PlugUI/privateapi/core.py in streamfile
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(f.name) ...
▶ Local vars
/usr/lib/python2.7/site-packages/django/http/init.py in setitem
header, value = self._convert_to_ascii(header, value) ...
▶ Local vars
/usr/lib/python2.7/site-packages/django/http/init.py in _convert_to_ascii
value = value.encode('us-ascii') ...
▶ Local vars
Request information

GET
No GET data
POST
No POST data
FILES
No FILES data
COOKIES
No cookie data
META
Variable Value
SERVER_SOFTWARE
'CherryPy/3.2.0 Server'
SCRIPT_NAME
u''
ACTUAL_SERVER_PROTOCOL
'HTTP/1.1'
REQUEST_METHOD
'GET'
PATH_INFO
u'/files/download/ZmI4ZDc3Mj'
SERVER_PROTOCOL
'HTTP/1.1'
QUERY_STRING
''
HTTP_ACCEPT_CHARSET
'ISO-8859-1,utf-8;q=0.7,;q=0.3'
HTTP_USER_AGENT
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1'
HTTP_CONNECTION
'keep-alive'
REMOTE_PORT
'56915'
SERVER_NAME
'localhost'
REMOTE_ADDR
'77.4.132.153'
wsgi.url_scheme
'http'
SERVER_PORT
'8888'
wsgi.input
<cherrypy.wsgiserver.KnownLengthRFile object at 0xb86310>
HTTP_HOST
'77.4.132.153:8888'
wsgi.multithread
True
REQUEST_URI
'/files/download/ZmI4ZDc3Mj'
HTTP_ACCEPT
'text/html,application/xhtml+xml,application/xml;q=0.9,
/;q=0.8'
wsgi.version
(1, 0)
wsgi.run_once
False
wsgi.errors
<open file '/dev/null', mode 'a+' at 0x183d30>
wsgi.multiprocess
False
HTTP_ACCEPT_LANGUAGE
'en-US,en;q=0.8,de;q=0.6,it;q=0.4'
HTTP_ACCEPT_ENCODING
'gzip,deflate,sdch'
Settings
Using settings module PlugUI.settings
Setting Value
USE_L10N
False
USE_THOUSAND_SEPARATOR
False
LANGUAGE_CODE
'en-us'
ROOT_URLCONF
'urls'
MANAGERS
()
DEFAULT_CHARSET
'utf-8'
STATIC_ROOT
''
TEST_DATABASE_CHARSET
None
MESSAGE_STORAGE
'django.contrib.messages.storage.user_messages.LegacyFallbackStorage'
DATABASE_HOST
''
IGNORABLE_404_STARTS
('/cgi-bin/', '/vti_bin', '/vti_inf')
SEND_BROKEN_LINK_EMAILS
False
URL_VALIDATOR_USER_AGENT
'Django/1.3 (http://www.djangoproject.com)'
STATICFILES_FINDERS
('django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder')
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
'sessionid'
COMMENTS_MODERATORS_GROUP
None
TIME_INPUT_FORMATS
('%H:%M:%S', '%H:%M')
DATABASES
{'default': {'ENGINE': 'django.db.backends.sqlite3',
'HOST': '',
'NAME': '/var/lib/PlugUI/db.sqlite3',
'OPTIONS': {},
'PASSWORD': '
******************
',
'PORT': '',
'TEST_CHARSET': None,
'TEST_COLLATION': None,
'TEST_MIRROR': None,
'TEST_NAME': None,
'TIME_ZONE': '',
'USER': ''}}
TEST_DATABASE_NAME
None
FILE_UPLOAD_PERMISSIONS
None
FILE_UPLOAD_HANDLERS
('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')
DEFAULT_CONTENT_TYPE
'text/html'
APPEND_SLASH
True
FIRST_DAY_OF_WEEK
0
DATABASE_ROUTERS
[]
YEAR_MONTH_FORMAT
'F Y'
STATICFILES_STORAGE
'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHES
{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': ''}}
SERVER_EMAIL
'root@localhost'
SESSION_COOKIE_PATH
'/'
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico', '.php')
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
USE_I18N
False
THOUSAND_SEPARATOR
','
SECRET_KEY
'**
'
LANGUAGE_COOKIE_NAME
'django_language'
FILE_UPLOAD_TEMP_DIR
None
TRANSACTIONS_MANAGED
False
LOGGING_CONFIG
'django.utils.log.dictConfig'
TEMPLATE_LOADERS
('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader')
TEMPLATE_DEBUG
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
TEST_DATABASE_COLLATION
None
FORCE_SCRIPT_NAME
None
CACHE_BACKEND
'locmem://'
SESSION_COOKIE_SECURE
False
CSRF_COOKIE_DOMAIN
None
FILE_CHARSET
'utf-8'
DEBUG
True
SESSION_FILE_PATH
None
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
INSTALLED_APPS
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'users',
'privateapi',
'system',
'files',
'apps',
'home']
LANGUAGES
(('ar', 'Arabic'),
('az', 'Azerbaijani'),
('bg', 'Bulgarian'),
('bn', 'Bengali'),
('bs', 'Bosnian'),
('ca', 'Catalan'),
('cs', 'Czech'),
('cy', 'Welsh'),
('da', 'Danish'),
('de', 'German'),
('el', 'Greek'),
('en', 'English'),
('en-gb', 'British English'),
('es', 'Spanish'),
('es-ar', 'Argentinian Spanish'),
('es-mx', 'Mexican Spanish'),
('es-ni', 'Nicaraguan Spanish'),
('et', 'Estonian'),
('eu', 'Basque'),
('fa', 'Persian'),
('fi', 'Finnish'),
('fr', 'French'),
('fy-nl', 'Frisian'),
('ga', 'Irish'),
('gl', 'Galician'),
('he', 'Hebrew'),
('hi', 'Hindi'),
('hr', 'Croatian'),
('hu', 'Hungarian'),
('id', 'Indonesian'),
('is', 'Icelandic'),
('it', 'Italian'),
('ja', 'Japanese'),
('ka', 'Georgian'),
('km', 'Khmer'),
('kn', 'Kannada'),
('ko', 'Korean'),
('lt', 'Lithuanian'),
('lv', 'Latvian'),
('mk', 'Macedonian'),
('ml', 'Malayalam'),
('mn', 'Mongolian'),
('nl', 'Dutch'),
('no', 'Norwegian'),
('nb', 'Norwegian Bokmal'),
('nn', 'Norwegian Nynorsk'),
('pa', 'Punjabi'),
('pl', 'Polish'),
('pt', 'Portuguese'),
('pt-br', 'Brazilian Portuguese'),
('ro', 'Romanian'),
('ru', 'Russian'),
('sk', 'Slovak'),
('sl', 'Slovenian'),
('sq', 'Albanian'),
('sr', 'Serbian'),
('sr-latn', 'Serbian Latin'),
('sv', 'Swedish'),
('ta', 'Tamil'),
('te', 'Telugu'),
('th', 'Thai'),
('tr', 'Turkish'),
('uk', 'Ukrainian'),
('ur', 'Urdu'),
('vi', 'Vietnamese'),
('zh-cn', 'Simplified Chinese'),
('zh-tw', 'Traditional Chinese'))
DATABASE_ENGINE
''
DATABASE_NAME
''
COMMENTS_FIRST_FEW
0
PREPEND_WWW
False
SESSION_COOKIE_HTTPONLY
False
DATABASE_PORT
''
DEBUG_PROPAGATE_EXCEPTIONS
False
MONTH_DAY_FORMAT
'F j'
PLUGAPPS_LIST
('minidlna', 'samba')
LOGIN_URL
'/users/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
TIME_FORMAT
'P'
DATE_INPUT_FORMATS
('%Y-%m-%d',
'%m/%d/%Y',
'%m/%d/%y',
'%b %d %Y',
'%b %d, %Y',
'%d %b %Y',
'%d %b, %Y',
'%B %d %Y',
'%B %d, %Y',
'%d %B %Y',
'%d %B, %Y')
CSRF_COOKIE_NAME
'csrftoken'
EMAIL_HOST_PASSWORD
'**
'
PASSWORD_RESET_TIMEOUT_DAYS
'**
'
CACHE_MIDDLEWARE_ALIAS
'default'
SESSION_SAVE_EVERY_REQUEST
False
ADMIN_MEDIA_PREFIX
'/media/'
NUMBER_GROUPING
0
SESSION_ENGINE
'django.contrib.sessions.backends.db'
CSRF_FAILURE_VIEW
'django.views.csrf.csrf_failure'
COMMENTS_SKETCHY_USERS_GROUP
None
LOGIN_REDIRECT_URL
'/home/'
LOGGING
{'disable_existing_loggers': False,
'handlers': {'mail_admins': {'class': 'django.utils.log.AdminEmailHandler',
'level': 'ERROR'}},
'loggers': {'django.request': {'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True}},
'version': 1}
CACHE_MIDDLEWARE_KEY_PREFIX
''
LOCALE_PATHS
()
TEMPLATE_STRING_IF_INVALID
''
COMMENTS_ALLOW_PROFANITIES
False
LOGOUT_URL
'/accounts/logout/'
EMAIL_USE_TLS
False
TEMPLATE_DIRS
('/opt/PlugUI/views',)
FIXTURE_DIRS
()
EMAIL_HOST
'localhost'
DATE_FORMAT
'N j, Y'
MEDIA_ROOT
''
ADMINS
()
FORMAT_MODULE_PATH
None
DEFAULT_FROM_EMAIL
'webmaster@localhost'
STATICFILES_DIRS
()
MEDIA_URL
''
DATETIME_FORMAT
'N j, Y, P'
EMAIL_SUBJECT_PREFIX
'[Django] '
SITE_ID
1
DISALLOWED_USER_AGENTS
()
ALLOWED_INCLUDE_ROOTS
()
STATIC_DOC_ROOT
'/opt/PlugUI/static'
DECIMAL_SEPARATOR
'.'
SHORT_DATE_FORMAT
'm/d/Y'
DATABASE_USER
''
TEST_RUNNER
'django.test.simple.DjangoTestSuiteRunner'
TIME_ZONE
''
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
EMAIL_BACKEND
'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_TABLESPACE
''
TEMPLATE_CONTEXT_PROCESSORS
('django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'custom_context.globals')
SESSION_COOKIE_AGE
1209600
SETTINGS_MODULE
'PlugUI.settings'
USE_ETAGS
False
LANGUAGES_BIDI
('he', 'ar', 'fa')
DEFAULT_INDEX_TABLESPACE
''
INTERNAL_IPS
()
STATIC_URL
None
EMAIL_PORT
25
SHORT_DATETIME_FORMAT
'm/d/Y P'
ABSOLUTE_URL_OVERRIDES
{}
DATABASE_OPTIONS
{}
CACHE_MIDDLEWARE_SECONDS
600
BANNED_IPS
()
DATETIME_INPUT_FORMATS
('%Y-%m-%d %H:%M:%S',
'%Y-%m-%d %H:%M',
'%Y-%m-%d',
'%m/%d/%Y %H:%M:%S',
'%m/%d/%Y %H:%M',
'%m/%d/%Y',
'%m/%d/%y %H:%M:%S',
'%m/%d/%y %H:%M',
'%m/%d/%y')
DATABASE_PASSWORD
'**
'
ADMIN_FOR
()
COMMENTS_BANNED_USERS_GROUP
None
EMAIL_HOST_USER
''
PROFANITIES_LIST
'**
*****************'
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant