[ruby-core:60935] [ruby-trunk - Bug #9273] parse_resolv_conf fails with unicode comments in /etc/resolvconf.c

From: naruse@...
Date: 2014-02-21 09:09:03 UTC
List: ruby-core #60935
Issue #9273 has been updated by Yui NARUSE.

Backport changed from 1.9.3: DONE, 2.0.0: DONE, 2.1: REQUIRED to 1.9.3: DON=
E, 2.0.0: DONE, 2.1: DONE

r45075.

----------------------------------------
Bug #9273: parse_resolv_conf fails with unicode comments in /etc/resolvconf=
.c
https://bugs.ruby-lang.org/issues/9273#change-45332

* Author: Vit Ondruch
* Status: Closed
* Priority: Normal
* Assignee:=20
* Category:=20
* Target version:=20
* ruby -v: ruby -v: ruby 2.1.0dev (2013-12-20 trunk 44303) [x86_64-linux]
* Backport: 1.9.3: DONE, 2.0.0: DONE, 2.1: DONE
----------------------------------------
=3Dbegin
This is content of my resolve.conf:

 $ cat /etc/resolv.conf=20
 # Generated by NetworkManager
 domain redhat.com
 search redhat.com
 nameserver 10.38.5.26
 nameserver 10.35.255.14
 nameserver 213.46.172.36
 # POZN=C3=81MKA: p=C5=99eklada=C4=8D adres z libc nem=C5=AF=C5=BEe podporo=
vat v=C3=ADce ne=C5=BE 3 jmenn=C3=A9 servery.
 # Jmenn=C3=A9 servery uveden=C3=A9 v n=C3=A1sleduj=C3=ADc=C3=ADm seznamu n=
elze rozpoznat.
 nameserver 213.46.172.37
 nameserver 192.168.0.1
=20
As you can see, NetworkManager inserts there some localized comment. Later,=
 when I run the Ruby's test suite with LANG=3DC (this is default for Fedora=
 build system), I observer error:

   1) Error:
 TestGemRemoteFetcher#test_download_to_cache:
 ArgumentError: invalid byte sequence in US-ASCII
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:926:in `sub!'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:926:in `block (2=
 levels) in parse_resolv_conf'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:925:in `each'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:925:in `block in=
 parse_resolv_conf'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:924:in `open'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:924:in `parse_re=
solv_conf'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:956:in `default_=
config_hash'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:977:in `block in=
 lazy_initialize'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:970:in `synchron=
ize'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:970:in `lazy_ini=
tialize'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:358:in `block in=
 lazy_initialize'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:356:in `synchron=
ize'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:356:in `lazy_ini=
tialize'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:516:in `fetch_re=
source'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:510:in `each_res=
ource'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/resolv.rb:491:in `getresou=
rce'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/remote_fetcher.rb=
:89:in `api_endpoint'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/source.rb:42:in `=
api_uri'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/source.rb:126:in =
`fetch_spec'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/spec_fetcher.rb:1=
71:in `block in spec_for_dependency'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/spec_fetcher.rb:1=
69:in `each'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/spec_fetcher.rb:1=
69:in `spec_for_dependency'
     /builddir/build/BUILD/ruby-2.1.0-r44303/lib/rubygems/remote_fetcher.rb=
:106:in `download_to_cache'
     /builddir/build/BUILD/ruby-2.1.0-r44303/test/rubygems/test_gem_remote_=
fetcher.rb:400:in `test_download_to_cache'

The attached patch ignores such error and should be sufficient to fix this =
issue IMO. Not sure if I should not contact NM developers, but anybody else=
 might insert there some localized strings as well, so Ruby should be proba=
bly more robust in this case.
=3Dend


---Files--------------------------------
0001-Ignore-encoding-issues.patch (1.08 KB)
0001-Ignore-encoding-issues.patch (971 Bytes)


--=20
http://bugs.ruby-lang.org/

In This Thread

Prev Next