Zim

"Internal Server Error" when page name has non-ASCII symbols

Bug #1698784 reported by Aino Neko
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Zim
New
Undecided
Unassigned

Bug Description

When run Zim Web server, the pages non-pure-ASCII symbols lead to "Internal Server Error" displayed in browser.

Version of zim: 0.66 and above (I have tried 0.66 and 0.67-rc2).
With version 0.65 this error did not happen.

How to reproduce:
create sub-page with name "Français" (note the "c with cedilla"), run server, click the page.

The relevant messages from zim -D:

ERROR: Unexpected error:
Traceback (most recent call last):
  File "/home/neko/work/_misc/zim-desktop-wiki/zim/www.py", line 226, in __call__
    path = self.notebook.pages.lookup_from_user_input(pagename)
  File "/home/neko/work/_misc/zim-desktop-wiki/zim/notebook/index/pages.py", line 652, in lookup_from_user_input
    source, href, ignore_link_placeholders=False)
  File "/home/neko/work/_misc/zim-desktop-wiki/zim/notebook/index/pages.py", line 325, in resolve_link
    return self.resolve_pagename(ROOT_PATH, href.parts())
  File "/home/neko/work/_misc/zim-desktop-wiki/zim/notebook/index/pages.py", line 405, in resolve_pagename
    page_id, pagename, branch = self._resolve_pagename(parent, names)
  File "/home/neko/work/_misc/zim-desktop-wiki/zim/notebook/index/pages.py", line 435, in _resolve_pagename
    (page_id, "%:"+basename)
ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
127.0.0.1 - - [19/Jun/2017 17:17:16] "GET /Home/Fran%C3%A7ais.html HTTP/1.1" 500 21

Python:
DEBUG: Python version is sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)
DEBUG: Platform is posix

Linux:
$uname -a
Linux venus 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux
$ lsb_release -d
Description: BunsenLabs GNU/Linux 8.7 (Hydrogen)

Revision history for this message
Otto Urpelainen (oturpe) wrote :

Also, if the notebook name itself contains a non-ascii character, every page apart from root gives an Internal Server Error. In that case, however, the error message is different. Here log from trying to open page "Page with only ascii characters in the name" in notebook "ääkköset web server" using the embedded web server:

[otto@ottovain Muiden]$ zim --server --port 8086 ~/Ohjelmistoprojektit/Testit/Zim/ääkköset\ web\ server/
INFO: This is zim 0.67-rc2
INFO: Loading template from: /usr/share/zim/templates/html/Default.html
INFO: No VCS detected
INFO: Serving HTTP on ottovain port 8086...
127.0.0.1 - - [19/Jul/2017 08:38:22] "GET / HTTP/1.1" 200 7032
127.0.0.1 - - [19/Jul/2017 08:38:22] "GET /favicon.ico HTTP/1.1" 200 1150
ERROR: Unexpected error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/zim/www.py", line 230, in __call__
    content = self.render_page(page)
  File "/usr/lib/python2.7/site-packages/zim/www.py", line 295, in render_page
    prevpage=self.notebook.pages.get_previous(page) if not page.isroot else None,
  File "/usr/lib/python2.7/site-packages/zim/notebook/index/pages.py", line 562, in get_previous
    raise IndexNotFoundError, 'No such page: %s' % path
IndexNotFoundError: No such page: Page_with_only_ascii_characters_in_the_name
127.0.0.1 - - [19/Jul/2017 08:38:23] "GET /Page_with_only_ascii_characters_in_the_name.html HTTP/1.1" 500 21
127.0.0.1 - - [19/Jul/2017 08:38:23] "GET /favicon.ico HTTP/1.1" 200 1150

Revision history for this message
zwn (zwn) wrote :

I see the same problem on Windows.

Revision history for this message
Aino Neko (ainoneko) wrote :

I tried to fix it where it crashes by this pull request at GitHub: https://github.com/jaap-karssenberg/zim-desktop-wiki/pull/394

But maybe it should be fixed in some other way, to prevent non-Unicode strings from appearing there.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.