Project

General

Profile

Actions

Bug #4110

closed

ホスト名の先頭が数字であるとき、WEBrickのテストでErrorが出る

Added by kyanagi (Kouhei Yanagita) almost 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]
Backport:
[ruby-dev:42672]

Description

=begin
ホスト名の先頭が数字であるような環境において、WEBrickのテストでErrorが出ます。

これは、WEBrick::HTTPRequest#parse_uriの中においてURI#host=でホスト名を設定する際、
先頭が数字であるような(ドットを含まない)ホスト名は許されないので例外が発生しているためです。

ひとまず、設定の:ServerNameを'localhost'にしてみたらテストは通りました。

$ ~/local/ruby-trunk/bin/ruby -v test/webrick/test_filehandler.rb
ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]
test/webrick/test_filehandler.rb:187: warning: assigned but unused variable - this_file
test/webrick/test_filehandler.rb:202: warning: assigned but unused variable - this_file
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:623: warning: assigned but unused variable - ac
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:624: warning: assigned but unused variable - tc
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - canon
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - sw
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - cn
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:446: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:13536: warning: assigned but unused variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:447: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:13536: warning: assigned but unused variable - s
Run options:

Running tests:

..E....

Finished tests in 0.657798s, 10.6416 tests/s, 83.6123 assertions/s.

  1. Error:
    test_make_partial_content(WEBrick::TestFileHandler):
    WEBrick::HTTPStatus::BadRequest: bad URI /'. test/webrick/test_filehandler.rb:35:in make_range_response'
    test/webrick/test_filehandler.rb:47:in `test_make_partial_content'

7 tests, 55 assertions, 0 failures, 1 errors, 0 skips

$ ~/local/ruby-trunk/bin/ruby -v test/webrick/test_httprequest.rb
ruby 1.9.3dev (2010-12-02 trunk 30021) [x86_64-linux]
test/webrick/test_httprequest.rb:321: warning: ambiguous first argument; put parentheses or even spaces
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:623: warning: assigned but unused variable - ac
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/minitest/unit.rb:624: warning: assigned but unused variable - tc
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - canon
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - sw
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:232: warning: assigned but unused variable - cn
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:446: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:14640: warning: assigned but unused variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:447: warning: shadowing outer local variable - s
/home/yanagi/local/ruby-trunk/lib/ruby/1.9.1/optparse.rb:14640: warning: assigned but unused variable - s
Run options:

Running tests:

..EE.EEE.E....

Finished tests in 0.015776s, 887.4239 tests/s, 3866.6329 assertions/s.

  1. Error:
    test_continue_not_sent(TestWEBrickHTTPRequest):
    WEBrick::HTTPStatus::BadRequest: bad URI /path'. test/webrick/test_httprequest.rb:332:in test_continue_not_sent'

  2. Error:
    test_continue_sent(TestWEBrickHTTPRequest):
    WEBrick::HTTPStatus::BadRequest: bad URI /path'. test/webrick/test_httprequest.rb:316:in test_continue_sent'

  3. Error:
    test_parse_09(TestWEBrickHTTPRequest):
    WEBrick::HTTPStatus::BadRequest: bad URI /'. test/webrick/test_httprequest.rb:12:in test_parse_09'

  4. Error:
    test_parse_10(TestWEBrickHTTPRequest):
    WEBrick::HTTPStatus::BadRequest: bad URI /'. test/webrick/test_httprequest.rb:29:in test_parse_10'

  5. Error:
    test_parse_11(TestWEBrickHTTPRequest):
    WEBrick::HTTPStatus::BadRequest: bad URI /path'. test/webrick/test_httprequest.rb:46:in test_parse_11'

  6. Error:
    test_parse_header2(TestWEBrickHTTPRequest):
    WEBrick::HTTPStatus::BadRequest: bad URI /foo/bar/../baz?q=a'. test/webrick/test_httprequest.rb:117:in test_parse_header2'

14 tests, 61 assertions, 0 failures, 6 errors, 0 skips
=end


Files

fix_webrick_test.diff (9.26 KB) fix_webrick_test.diff kyanagi (Kouhei Yanagita), 12/02/2010 10:22 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #2542: URI lib should be updated to RFC 3986Closednaruse (Yui NARUSE)01/01/2010Actions
Actions #1

Updated by naruse (Yui NARUSE) almost 14 years ago

=begin
RFC 2396 では以下の通りだったけれど、
hostport = host [ ":" port ]
host = hostname | IPv4address
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
toplabel = alpha | alpha *( alphanum | "-" ) alphanum
RFC 3986 で変わって許されるようになったんですね。とりあえず対処を入れます。
authority = [ userinfo "@" ] host [ ":" port ]
host = IP-literal / IPv4address / reg-name
reg-name = *( unreserved / pct-encoded / sub-delims )
=end

Actions #2

Updated by naruse (Yui NARUSE) almost 14 years ago

  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)

=begin

=end

Actions #3

Updated by taca (Takahiro Kambe) almost 14 years ago

=begin
In message
on Fri, 3 Dec 2010 02:36:34 +0900,
Yui NARUSE wrote:

RFC 2396 では以下の通りだったけれど、
hostport = host [ ":" port ]
host = hostname | IPv4address
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
toplabel = alpha | alpha *( alphanum | "-" ) alphanum
RFC 3986 で変わって許されるようになったんですね。とりあえず対処を入れます。
authority = [ userinfo "@" ] host [ ":" port ]
host = IP-literal / IPv4address / reg-name
reg-name = *( unreserved / pct-encoded / sub-delims )
元々、DNS的ドメイン名は RFC-1123 で「ホスト名の最初が英文字だけ」とい
う制限を外しているので、 RFC-2936 の定義がそれを失念してたという感じじゃ
ないでしょうか。変わったというより、誤りを正したという感じで。

--
神戸 隆博 (かんべ たかひろ) at 仕事場

=end

Actions #4

Updated by naruse (Yui NARUSE) almost 14 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r30089.
Kouhei, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0