Project

General

Profile

Actions

Bug #7155

closed

Invalid byte sequence in US-ASCII when using open-air

Added by t0d0r (Todor Dragnev) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
1.9.3p286
Backport:
[ruby-core:47964]

Description

Invalid byte sequence in US-ASCII on ruby 1.9.3

I receive that error when trying to open url with bulgarian text (utf-8: "История"). It seems that the problem is in uri/common.rb from ruby standard library...

adding str.force_encoding(Encoding::BINARY) to following method fix the problem

class URI::Parser
def escape(str, unsafe = @regexp[:UNSAFE])
unless unsafe.kind_of?(Regexp)
# perhaps unsafe is String object
unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false)
end
str.force_encoding(Encoding::BINARY) # FIX
str.gsub(unsafe) do
us = $&
tmp = ''
us.each_byte do |uc|
tmp << sprintf('%%%02X', uc)
end
tmp
end.force_encoding(Encoding::US_ASCII)
end
end

One more suggestion - maybe US_ASCII must be replaced to Encoding::BINARY too?

Updated by t0d0r (Todor Dragnev) over 11 years ago

Sorry, syntax error in title "open-air" =>is URI lib from core library ./src/ruby-1.9.3-p286/lib/uri/common.rb

Updated by mame (Yusuke Endoh) over 11 years ago

  • Status changed from Open to Rejected

Closing because OP seemed to re-register another ticket #7156.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0