Edgewall Software

Ticket #3663 (new defect)

Opened 2 years ago

Last modified 5 weeks ago

Chinese folder or file name error

Reported by: niijyeni@… Owned by: cboos
Priority: normal Milestone: 0.11.3
Component: web frontend/mod_python Version: devel
Severity: normal Keywords: apache cgi unicode verify
Cc:

Description (last modified by cboos) (diff)

i clicked folder of file(encoding:utf-8) trac report this message:


Traceback (most recent call last):
  File "C:\Python23\Lib\site-packages\trac\web\main.py", line 335, in dispatch_request
    dispatcher.dispatch(req)
  File "C:\Python23\Lib\site-packages\trac\web\main.py", line 167, in dispatch
    if not req.path_info or req.path_info == '/':
  File "C:\Python23\lib\site-packages\trac\web\api.py", line 193, in <lambda>
    path_info = property(fget=lambda self: self.environ.get('PATH_INFO', '').decode('utf-8'),
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa6 in position 17: unexpected code byte

Attachments

a1.PNG (14.2 KB) - added by niijyeni@… 2 years ago.
error picture
a2.PNG (14.2 KB) - added by niijyeni@… 2 years ago.
error picture2
a3.PNG (7.6 KB) - added by niijyeni@… 2 years ago.
error picture3

Change History

  Changed 2 years ago by cboos

  • keywords unicode needinfo added
  • owner changed from jonas to cboos

Can you please dump the byte sequence corresponding to the UTF-8 encoding of that path, so that I can try to reproduce the issue?

Changed 2 years ago by niijyeni@…

error picture

Changed 2 years ago by niijyeni@…

error picture2

  Changed 2 years ago by niijyeni@…

there two error picture.

  Changed 2 years ago by niijyeni@…

and a file save as ANSI Encoding,when browse whill raise a encoding error.

ÎÒÊǺÃÈË£¬²»ÊÇ»µÈË¡£

see picture a3

Changed 2 years ago by niijyeni@…

error picture3

follow-up: ↓ 5   Changed 2 years ago by mgood

I've tested the same filename found in the screenshot with FastCGI and tracd and it works for me. Be sure you're using the latest Trac source.

What web server are you using? Also, which frontend are you using with Trac: FastCGI, CGI, mod_python, or something else? Normally I would expect to see another Trac module above dispatch_request in the stack where it was called from, but that's not there in this traceback.

in reply to: ↑ 4   Changed 2 years ago by anonymous

Replying to mgood:

I've tested the same filename found in the screenshot with FastCGI and tracd and it works for me. Be sure you're using the latest Trac source. What web server are you using? Also, which frontend are you using with Trac: FastCGI, CGI, mod_python, or something else? Normally I would expect to see another Trac module above dispatch_request in the stack where it was called from, but that's not there in this traceback.


Apache 2.0.59(Win32) SVN 1.3.2 DAV 2 CGI IE 6

  Changed 2 years ago by niijyeni@…

??? I use

Apache 2.0.59(Win32)

SVN 1.3.2 DAV 2

CGI

IE 6

Windows XP

follow-up: ↓ 8   Changed 2 years ago by cboos

And what revision of Trac 0.10, exactly?

in reply to: ↑ 7   Changed 2 years ago by niijyeni@…

Replying to cboos:

And what revision of Trac 0.10, exactly?

Trac 0.10b1

follow-up: ↓ 10   Changed 2 years ago by cboos

  • keywords apache cgi win32 added; chinese removed
  • priority changed from high to normal
  • description modified (diff)
  • milestone changed from 0.10 to 0.10.1

Ok, so according to attachment:a2.PNG, the request was for path "vendor/试试中文.txt" (url = u'vendor/\u8bd5\u8bd5\u4e2d\u6587'), but then, the PATH_INFO CGI env variable contained something that had a byte 0xa8 in position 16... I couldn't find an encoding that would actually encode the above url to this, so I'm left wondering what to do here...

Perhaps you could add a print `self.environ.get('PATH_INFO', '')` statement in trac.web.api.py before line 193, in order to see the full sequence of bytes. From that, perhaps we could guess what Apache is doing.

Also, this issue is possibly related to: http://twiki.org/cgi-bin/view/Codev.ApacheTwoBreaksNonUTF8EncodedURLsOnWindows

In any case, this is not going to block 0.10...

in reply to: ↑ 9   Changed 2 years ago by anonymous

Replying to cboos:

... url = u'vendor/\u8bd5\u8bd5\u4e2d\u6587'), but then, the PATH_INFO CGI env variable contained something that had a byte 0xa8 in position 16...

Sorry, I meant url = u'/browser/vendor/\u8bd5\u8bd5\u4e2d\u6587', so that position 16 effectively corresponds to the first non-ascii character.

  Changed 2 years ago by cboos

#2981 was marked as duplicate.

  Changed 2 years ago by sid

  • keywords windows added; win32 removed

follow-up: ↓ 16   Changed 20 months ago by alexhalf@…

Hello all. I had the same problem. I have windows server 2003 (Russian locale), apache-2.0.52, trac-0.10.3 (is running as cgi), python-2.4.1.

I couldn't submit and view(get) file with filenames were consist of russian characters (Attachements). I couldn't get the same files from svn repository through trac (Browse Source).

I decided the problem the following way. I changed the trac/web/api.py file. Need change line 219: path_info = property(fget=lambda self: self.environ.get('PATH_INFO', ).decode('utf-8'), To: path_info = property(fget=lambda self: self.environ.get('PATH_INFO', ).decode('mbcs'),

It's all. Best regards, Alyabushev Alexander alexhalf@…

  Changed 20 months ago by cboos

#4003 closed as duplicate. The reporter of that ticket said that he tried to "update from encode('utf-8') to encode('mbcs') in api.py file" without success (btw, that was a few months before comment:13, so I wonder where that advice came from, initially).

  Changed 15 months ago by cboos

#5915 was closed as duplicate.

in reply to: ↑ 13   Changed 12 months ago by cboos

#6372 was closed as duplicate.

This is the suggested fix: Replying to alexhalf@gmail.com:

... I decided the problem the following way. I changed the trac/web/api.py file. Need change line 219:

    path_info = property(fget=lambda self: self.environ.get('PATH_INFO', '').decode('utf-8'),

To:

    path_info = property(fget=lambda self: self.environ.get('PATH_INFO', '').decode('mbcs'),

Please try it out. If that works, then also try to create/view wiki pages containing unicode characters, to check if they are still working with that change.

  Changed 5 months ago by cboos

  • keywords windows removed
  • component changed from version control/browser to web frontend/mod_python
  • milestone changed from 0.10.6 to 0.11.1

#7368 was closed as duplicate. That one is the first to be reported for a non-Windows platform.

Also that one is about mod_wsgi and not mod_python, but I think the root cause must be the same.

  Changed 5 weeks ago by cboos

  • keywords verify added; needinfo removed
  • milestone changed from 0.11.2 to 0.11.3

Still worth investigating/fixing one day, keeping on the -stable TODO list.

Add/Change #3663 (Chinese folder or file name error)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from cboos. Next status will be 'new'
The owner will change from cboos to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.