Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open files with spaces in name #1501

Closed
liayn opened this issue Jan 8, 2016 · 16 comments
Closed

Cannot open files with spaces in name #1501

liayn opened this issue Jan 8, 2016 · 16 comments

Comments

@liayn
Copy link

liayn commented Jan 8, 2016

When I try to click on a file in the web-ui which has a space in its name I get a 503 error.

Example URL: https://example.com/lib/a7dad841-1f33-4ca0-a50c-80f203455c99/file/TYPO3%20Update%20cmdline.txt

seahub_django_request.log holds:

2016-01-08 20:45:25,433 [ERROR] django.request:210 handle_uncaught_exception Internal Server Error: /lib/a7dad841-1f33-4ca0-a50c-80f2034b5c99/file/TYPO3 Update cmdline.txt/lib/a7dad841-1f33-4ca0-a50c-80f2034b5c99/file/TYPO3%20Update%20cmdline.txt
Traceback (most recent call last):
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/djang/core/handlers/base.py", line 113, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/opt/cloud/seafile-server-5.0.3/seahub/seahub/auth/decorators.py", line 26, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/opt/cloud/seafile-server-5.0.3/seahub/seahub/base/decorators.py", line 74, in _decorated
    return func(request, *args, **kwargs)
  File "/opt/cloud/seafile-server-5.0.3/seahub/seahub/views/file.py", line 363, in view_lib_file
    return _file_view(request, repo_id, path)
  File "/opt/cloud/seafile-server-5.0.3/seahub/seahub/views/file.py", line 384, in _file_view
    return render_error(request, _(u'File does not exist'))
  File "/opt/cloud/seafile-server-5.0.3/seahub/seahub/utils/__init__.py", line 150, in render_error
    context_instance=RequestContext(request))
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/shortcuts/__init__.py", line 29, in render_to_response
    return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/loader.py", line 177, in render_to_string
    return t.render(context_instance)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 140, in render
    return self._render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 830, in render
    bit = self.render_node(node, context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 844, in render_node
    return node.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/loader_tags.py", line 124, in render
    return compiled_parent._render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 830, in render
    bit = self.render_node(node, context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 844, in render_node
    return node.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/loader_tags.py", line 124, in render
    return compiled_parent._render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 830, in render
    bit = self.render_node(node, context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 844, in render_node
    return node.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/defaulttags.py", line 285, in render
    return nodelist.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 830, in render
    bit = self.render_node(node, context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 844, in render_node
    return node.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/defaulttags.py", line 285, in render
    return nodelist.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 830, in render
    bit = self.render_node(node, context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/base.py", line 844, in render_node
    return node.render(context)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/defaulttags.py", line 196, in render
    nodelist.append(node.render(context))
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/template/defaulttags.py", line 413, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/core/urlresolvers.py", line 522, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "/opt/cloud/seafile-server-5.0.3/seahub/thirdpart/Django-1.5.12-py2.6.egg/django/core/urlresolvers.py", line 415, in _reverse_with_prefix
    candidate = (prefix_norm + result) % dict(zip(prefix_args + params, unicode_args))
ValueError: unsupported format character 'U' (0x55) at index 55
@shoeper
Copy link
Collaborator

shoeper commented Feb 9, 2016

This is a setup specific issue caused by wrong encoding.

@shoeper shoeper closed this as completed Feb 9, 2016
@liayn
Copy link
Author

liayn commented Feb 10, 2016

@shoeper

This is a setup specific issue caused by wrong encoding.

Sorry, could you please elaborate what I did wrong?

@shoeper
Copy link
Collaborator

shoeper commented Feb 10, 2016

The problem does not occur with nginx and is due to some kind of wrong encoded URI send from your webserver to Seafile.

@liayn
Copy link
Author

liayn commented Feb 10, 2016

Hi @shoeper, thanks, ok, answer accepted, still I don't consider it fair to close a bug report, just because it works on your setup.

We use apache in front of seafile and use no options, which would contradict with what is written in the server manual.

Here is the vhost config:

<VirtualHost *:443>
  ServerName cloud.example.com

  Define siteroot /var/www/cloud
  DocumentRoot ${siteroot}/web

  SSLEngine On
  SSLCertificateFile /etc/....crt
  SSLCertificateKeyFile /etc/....key
  SSLCertificateChainFile /etc/....pem

  Alias /media  /opt/cloud/seafile-server-latest/seahub/media

  <Location /media>
    ProxyPass !
    Require all granted
  </Location>

  ProxyPass /seafhttp http://127.0.0.1:8082
  ProxyPassReverse /seafhttp http://127.0.0.1:8082
  RewriteRule ^/seafhttp - [QSA,L]

  SetEnvIf Request_URI . proxy-fcgi-pathinfo=1
  SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  ProxyPass / fcgi://127.0.0.1:8000/

  ErrorLog  ${siteroot}/logs/error.log
  CustomLog ${siteroot}/logs/access.log combined
</VirtualHost>

Don't get me wrong, I report this issue here not because I want to steal your precious time, but because I want to make this product better. Even if the solution is to put a note/hint/warning in the docs that some certain setup will cause troubles.

Do you need any more information in order to tackle the culprit?
Thanks.

@shoeper
Copy link
Collaborator

shoeper commented Feb 10, 2016

Can you try this SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape

(Source: #1258)

@liayn
Copy link
Author

liayn commented Feb 10, 2016

Yes works! Thank you very much.

This should really be noted in http://manual.seafile.com/deploy_windows/deploy_with_apache.html.
Generally this page would deserve a small update, specifically for ProxyPass usage and addressing fastcgi via fcg:// both with TCP and sockets.

(I swear I searched for existing tickets first, but obviously didn't realize the referenced ticket.)

@shoeper
Copy link
Collaborator

shoeper commented Feb 10, 2016

Maybe you can work on a pr for the seafile server manual repo.

@liayn
Copy link
Author

liayn commented Feb 10, 2016

Will do!

@liayn
Copy link
Author

liayn commented Feb 12, 2016

@hede5562
Copy link

For anyone using Apache pre 2.4.11 (like Debian stable/jessie) the solution via apache config
proxy-fcgi-pathinfo=unescape is invalid. As a workaround you can use phusion/passenger#1828 translated to seafile:

+++ seafile-server-6.0.6/seahub/thirdpart/Django-1.8.16-py2.7.egg/django/core/handlers/wsgi.py.new	2016-11-25 12:18:21.269997170 +0100
@@ -19,6 +19,7 @@ from django.utils import datastructures,
 from django.utils.deprecation import RemovedInDjango19Warning
 from django.utils.encoding import force_str, force_text
 from django.utils.functional import cached_property
+from urllib2 import unquote
 
 logger = logging.getLogger('django.request')
 
@@ -206,6 +207,7 @@ def get_path_info(environ):
     """
     path_info = get_bytes_from_wsgi(environ, 'PATH_INFO', '/')
 
+    path_info = unquote(path_info)
     return path_info.decode(UTF_8)

Don't forget to enable unquote_path_info in your wsgidav configuration if using webdav...

@ghost
Copy link

ghost commented Dec 22, 2016

Hi @hede5562

this works for us as well (Debian Jessie). Thanks for the info. Will this fix make it in the next Seafile release, or do we have to do this again after next update?

Thanks again! Great job!

@klangborste
Copy link

klangborste commented Jan 28, 2017

Hey @antares2001,

as i see you must also redo this for the next version. I was at the same point at the moment after upgrading to 6.0.7, had the exact same situation as described here.
I also edited the wsgi.py with this workaround in 6.0.6.

:~#diff seafile-server-6.0.6/seahub/thirdpart/Django-1.8.16-py2.7.egg/django/core/handlers/wsgi.py seafile-server-6.0.7/seahub/thirdpart/Django-1.8.16-py2.7.egg/django/core/handlers/wsgi.py

22d21
< from urllib2 import unquote
210d208
<     path_info = unquote(path_info)

@klangborste
Copy link

klangborste commented Jan 28, 2017

Hi @hede5562,

thanks for the very helpful information.
could you please be more detailed about this:

Don't forget to enable unquote_path_info in your wsgidav configuration if using webdav...

Which file(s) and what should there be changed/edited?
Thanks in advance.

@tobiasmayr
Copy link

tobiasmayr commented Jun 1, 2017

Hi everyone,

I just had the same issue on my server, and since I am running Ubuntu 14.04 and thus was on apache 2.4.7, I used Ondrej's repo to upgrade to the newest stable apache2 (as suggested here)

sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get upgrade

Fixed the issue :)

@evdbovenkamp
Copy link

I spent a lot of time to solve this problem and there is an easy solution; If this problem happens when you have Ubuntu 14.0x install, do a upgrade to the latest version with the command; do-release-upgrade
The problem is the Apache version. This solves the problem, because with the new Ubuntu version, also a new version of Apache will be installed.

@tobiasmayr
Copy link

@evdbovenkamp I'd argue that doing a release upgrade is not "easy" at all ^^ depending on your setup, it can break EVERYTHING. But it's an alternative solution, that's true ;)

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

No branches or pull requests

6 participants