2011-10-03 87 views
1

由於問號,我得到一個錯誤。 Someone had the same problem but the answer that was given返回錯誤:如何防止?在Ruby中導致Bad URI錯誤的字符?

uninitialized constant URI::Parser (NameError) 

這是我的代碼(在rackup文件):

require 'rubygems' 
require 'rack' 
require 'time' 
require 'set' 
require 'uri' 
require 'domain_constants' 
require "digest/sha1" 

URI::DEFAULT_PARSER = URI::Parser.new(:UNRESERVED => URI::REGEXP::PATTERN::UNRESERVED + '?') 

請幫我解決這個問題的,我已經花了4小時試圖數字出來這一個。

PS:

我首先得到的錯誤是:

ERROR bad URI `/font/dorianclm-book-webfont.eot?)%20format("eot"),%20url(http://mysite.co:9292/font/dorianclm-book-webfont),%20url(http://mysite.co:9292/font/dorianclm-book-webfont'. 
+0

你能告訴你如何得到帶有問號的錯誤嗎?我用管道(|)看過它,但試圖在1.8.7上對舊應用程序的幾個URL進行卷曲,並且我無法重現該錯誤。你使用哪個網絡服務器? – tardate

+0

@tradate我加了錯誤 – Tom

+0

你有沒有對url構造的控制權?它看起來像雙引號引起的問題(「 - > subst與%22)。這適用於我:http:// server/path?)%20format(%22eot%22),%20url(http:// mysite.co:9292/font/dorianclm-book-webfont),%20url(http://mysite.co:9292/font/dorianclm-book-webfont) – tardate

回答

0

URI :: DEFAULT_PARSER猴子補丁只適用於Ruby 1.9(並不是一個非常好的東西必須做的第一個地方)。

1.8中的URI模塊具有相同的問題,但如果在基本上不重寫其大塊的情況下進行修補會更困難。

如果您遇到默認URI解析的侷限性,最好的方法是使用除WEBrick之外的其他內容(例如nginx)。

+0

我在apache後面使用Passenger,我不能升級到1.9,也不相信可以從WEBrick更改 – Tom

相關問題