Skip to content

* lib/webrick/httpservlet/filehandler.rb: some fix on win platform or not utf-8 platform #314

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

Closed
wants to merge 1 commit into from

Conversation

windwiny
Copy link

/cc @nobu

@zzak
Copy link
Member

zzak commented Jul 11, 2013

@windwiny Do you have a ticket in the bug tracker for this yet?

Can you reproduce a failing test or script?

@nobu ping!

@zzak
Copy link
Member

zzak commented Oct 15, 2013

@windwiny ping!

Could you give some more feedback?

@windwiny
Copy link
Author

@zzak hi, did you have a windows system?

i am test is in CP936, a directory include filename 桌面

run webrick in console:

ruby -run -e httpd . -p 8000

and open link in IE:

http://127.0.0.1:8000/

the IE show:

Internal Server Error
incompatible encoding regexp match (ASCII-8BIT regexp with GBK string) 
--------------------------------------------------------------------------------

WEBrick/1.3.1 (Ruby/2.0.0/2013-06-27) at 127.0.0.1:8000 

console log:

[2013-10-18 14:54:48] INFO  WEBrick 1.3.1
[2013-10-18 14:54:48] INFO  ruby 2.0.0 (2013-06-27) [i386-mingw32]
[2013-10-18 14:54:48] INFO  WEBrick::HTTPServer#start: pid=1560 port=8000
[2013-10-18 14:54:50] ERROR Encoding::CompatibilityError: incompatible encoding regexp match (ASCII-8BIT regexp with GBK string)
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httputils.rb:440:in `gsub'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httputils.rb:440:in `_escape'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httputils.rb:455:in `escape'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpservlet/filehandler.rb:465:in `block in set_dir_list'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpservlet/filehandler.rb:457:in `each'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpservlet/filehandler.rb:457:in `set_dir_list'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpservlet/filehandler.rb:218:in `do_GET'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpservlet/abstract.rb:106:in `service'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpservlet/filehandler.rb:213:in `service'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
        e:/ux/ruby2/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
localhost - - [18/Oct/2013:14:54:50 中国标准时间] "GET / HTTP/1.1" 500 350

@nobu
Copy link
Member

nobu commented Oct 18, 2013

Use of force_encoding don't seem appropriate.

@nobu
Copy link
Member

nobu commented Oct 21, 2013

chcp can't affect filesystem encoding, which is system-wide.

nobu added a commit to nobu/ruby that referenced this pull request Feb 2, 2014
* lib/webrick/httpservlet/filehandler.rb (set_dir_list): fix escape
  methods.  query is for links and should be escaped as HTTP, name
  should be escaped as a path.  [rubyGH-314]
nobu added a commit to nobu/ruby that referenced this pull request Feb 2, 2014
* lib/webrick/httpservlet/filehandler.rb (initialize): make encoding
  customizable.

* lib/webrick/httpservlet/filehandler.rb (prevent_directory_traversal):
  use the given encoding, and encoding of path_info has no sense.

* lib/webrick/httpservlet/filehandler.rb (set_dir_list): ditto.
  Fixes [rubyGH-314]
nobu added a commit to nobu/ruby that referenced this pull request Sep 22, 2015
* lib/webrick/httpservlet/filehandler.rb (set_dir_list): fix escape
  methods.  query is for links and should be escaped as HTTP, name
  should be escaped as a path.  [rubyGH-314]
nobu added a commit to nobu/ruby that referenced this pull request Sep 22, 2015
* lib/webrick/httpservlet/filehandler.rb (initialize): make encoding
  customizable.

* lib/webrick/httpservlet/filehandler.rb (prevent_directory_traversal):
  use the given encoding, and encoding of path_info has no sense.

* lib/webrick/httpservlet/filehandler.rb (set_dir_list): ditto.
  Fixes [rubyGH-314]
@hsbt
Copy link
Member

hsbt commented Oct 22, 2017

Can you address this patch to https://bugs.ruby-lang.org/projects/ruby-trunk/issues ?

Webrick is only handled on our redmine tracker. Thanks.

@hsbt hsbt closed this Oct 22, 2017
ioquatix pushed a commit to ioquatix/ruby that referenced this pull request Sep 30, 2020
kddnewton pushed a commit to kddnewton/ruby that referenced this pull request Jul 13, 2022
* Fix preprocessor define for YJIT_SUPPORTED_P

* Fix comment
kddnewton pushed a commit to kddnewton/ruby that referenced this pull request Jul 21, 2022
* Fix preprocessor define for YJIT_SUPPORTED_P

* Fix comment
jhawthorn pushed a commit to jhawthorn/ruby that referenced this pull request Aug 3, 2022
* Fix preprocessor define for YJIT_SUPPORTED_P

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

Successfully merging this pull request may close these issues.

5 participants