[Twisted-web] Problems with Twisted Web & non-standard file names...

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sun Nov 18 08:56:54 EST 2012

On 16 Nov, 02:49 pm, benjamin at schollnick.net wrote:
>I am in the process of writing, a "gallery" style web server 
>application using twisted....
>The main goal is to be able to browse, and access my image library, 
>without having to add the files to a database, etc....
>The issue I am having is with the URL processing....
>Standard ASCII, and non-extended characters are working fine....  And 
>I've tried using urllib.quote & urllib.quoteplus (along with unquote), 
>to solve this problem....
>But an URL with a dash (-) or number sign (#), or non-ASCII (eg 
>2012.7.1-撮影会-  de die in diem) prevents it working...
>The DASH or number sign will generally produce a 500 internal server 
>error, non-ascii, will allow me to transverse to the directory, but the 
>server fails to properly decode the URL, and none of the images 

Twisted Web should log an exception with a traceback any time it emits a 
500 error.  Have you checked the logs to see what exception is 

"#" has special meaning in a URL, and if you are typing it into a 
browser's location bar, then the browser is intentionally *not* sending 
it or anything following it.  You have to type %23 instead to represent 
a "#" that is part of the PATH of a URL.  A literal "#" signifies the 
start of the "fragment" portion of the URL.

>What happens is....
>Server side -
>The Server decodes the request string, and transverse to the directory 
>structure in the URL.  For example, 
> would transverse into the 
>albums / Television / B5 directory....  And 
>would show the ADVDEST.JPG that is stored in the directory...
>The issue I am having is that the POST request string is stopping at a 
>single quote mark...
>pre -  ['albums']
>post -  ['anime', '(C54) [RPG']
>RS /albums/anime/(C54) [RPG
>/Volumes/DVR Storage/MMAP/gallery/sites
>POST ['anime', '(C54) [RPG']
>ARGS {}
>The directory name is (c54) [rpg' company (toumi haruka)] wedding bell 
>(ah my goddess) [english][saha].
>Any one have any suggestions on how to solve this?  As I mentioned 
>URLlib.quote_plus / unquote_plus don't seem to make a difference....
>The one idea I had, was to send the web server an index, but that would 
>be a pain, since you would not be able to type in the directory, as a 
>shortcut...  You would only be able to transverse via the web GUI....
>         - Benjamin

More information about the Twisted-web mailing list