[rubygem-idn] Fix rubygem, encoding changes in Ruby 1.9 broke the tests and the native code

Shawn Starr spstarr at fedoraproject.org
Fri Feb 10 02:48:01 UTC 2012


commit 2ba90b1adcbc028da52f39645b387a96c912f400
Author: Shawn Starr <shawn.starr at rogers.com>
Date:   Thu Feb 9 21:47:55 2012 -0500

    Fix rubygem, encoding changes in Ruby 1.9 broke the tests and the native code

 rubygem-idn-0.0.2-Fix-Tests-for-ruby-1.9.x.patch |   51 +++++++++++
 rubygem-idn-0.0.2-Fix-for-ruby-1.9.x.patch       |   98 ++++++++++++++++++++++
 2 files changed, 149 insertions(+), 0 deletions(-)
---
diff --git a/rubygem-idn-0.0.2-Fix-Tests-for-ruby-1.9.x.patch b/rubygem-idn-0.0.2-Fix-Tests-for-ruby-1.9.x.patch
new file mode 100644
index 0000000..db90b3c
--- /dev/null
+++ b/rubygem-idn-0.0.2-Fix-Tests-for-ruby-1.9.x.patch
@@ -0,0 +1,51 @@
+diff -Nrup test/tc_Idna.rb test.fixed/tc_Idna.rb
+--- test/tc_Idna.rb	1969-12-31 19:00:00.000000000 -0500
++++ test.fixed/tc_Idna.rb	2012-02-09 21:27:01.111141164 -0500
+@@ -208,7 +208,7 @@ class Test_Idna < Test::Unit::TestCase
+ 
+   def test_toASCII_UNASSIGNED_ALLOWED
+     TESTCASES_UNASSIGNED.each do |key, val|
+-      rc = Idna.toASCII(val[0], IDN::Idna::ALLOW_UNASSIGNED)
++      rc = Idna.toASCII(val[0], IDN::Idna::ALLOW_UNASSIGNED).force_encoding('ASCII-8BIT')
+       assert_equal(val[1], rc, "TestCase #{key} failed")
+     end
+   end
+@@ -238,14 +238,14 @@ class Test_Idna < Test::Unit::TestCase
+ 
+   def test_toUnicode_JOSEFSSON
+     TESTCASES_JOSEFSSON.each do |key, val|
+-      rc = Idna.toUnicode(val[1])
++      rc = Idna.toUnicode(val[1]).force_encoding('UTF-8')
+       assert_equal(val[0], rc, "TestCase #{key} failed")
+     end
+   end
+ 
+   def test_toUnicode_UNASSIGNED_ALLOWED
+     TESTCASES_UNASSIGNED.each do |key, val|
+-      rc = Idna.toUnicode(val[1], IDN::Idna::ALLOW_UNASSIGNED)
++      rc = Idna.toUnicode(val[1], IDN::Idna::ALLOW_UNASSIGNED).force_encoding('UTF-8')
+       assert_equal(val[0], rc, "TestCase #{key} failed")
+     end
+   end
+@@ -266,7 +266,7 @@ class Test_Idna < Test::Unit::TestCase
+ 
+   def test_toUnicode_STD3_NOT_USED
+     TESTCASES_STD3.each do |key, val|
+-      rc = Idna.toUnicode(val[1])
++      rc = Idna.toUnicode(val[1]).force_encoding('UTF-8')
+       assert_equal(val[0], rc, "TestCase #{key} failed")
+     end
+   end
+diff -Nrup test/tc_Punycode.rb test.fixed/tc_Punycode.rb
+--- test/tc_Punycode.rb	1969-12-31 19:00:00.000000000 -0500
++++ test.fixed/tc_Punycode.rb	2012-02-09 21:27:34.513723573 -0500
+@@ -181,7 +181,7 @@ class Test_Punycode < Test::Unit::TestCa
+ 
+   def test_decode_RFC3492
+     TESTCASES_RFC3492.each do |key, val|
+-      rc = Punycode.decode(val[1])
++      rc = Punycode.decode(val[1]).force_encoding('UTF-8')
+       assert_equal(val[0], rc, "TestCase #{key} failed")
+     end
+   end
+Binary files test/.tc_Punycode.rb.swp and test.fixed/.tc_Punycode.rb.swp differ
diff --git a/rubygem-idn-0.0.2-Fix-for-ruby-1.9.x.patch b/rubygem-idn-0.0.2-Fix-for-ruby-1.9.x.patch
new file mode 100644
index 0000000..7a82ecb
--- /dev/null
+++ b/rubygem-idn-0.0.2-Fix-for-ruby-1.9.x.patch
@@ -0,0 +1,98 @@
+From 00eb5f07949341b8b98574b3d63366bd3d65fd21 Mon Sep 17 00:00:00 2001
+From: Michal Humpula <michal.humpula at hudrydum.cz>
+Date: Fri, 17 Sep 2010 17:25:54 +0200
+Subject: [PATCH] Fix for ruby 1.9.x
+
+---
+ ext/idna.c       |    4 ++--
+ ext/punycode.c   |    6 +++---
+ ext/stringprep.c |    6 +++---
+ 3 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/ext/idna.c b/ext/idna.c
+index d719579..ae7042d 100644
+--- a/ext/idna.c
++++ b/ext/idna.c
+@@ -85,7 +85,7 @@ static VALUE toASCII(int argc, VALUE argv[], VALUE self)
+     flags = 0x0000;
+   }
+ 
+-  rc = idna_to_ascii_8z(RSTRING(str)->ptr, &buf, flags);
++  rc = idna_to_ascii_8z(RSTRING_PTR(str), &buf, flags);
+ 
+   if (rc != IDNA_SUCCESS) {
+     xfree(buf);
+@@ -125,7 +125,7 @@ static VALUE toUnicode(int argc, VALUE argv[], VALUE self)
+     flags = 0x0000;
+   }
+ 
+-  rc = idna_to_unicode_8z8z(RSTRING(str)->ptr, &buf, flags);
++  rc = idna_to_unicode_8z8z(RSTRING_PTR(str), &buf, flags);
+ 
+   if (rc != IDNA_SUCCESS) {
+     xfree(buf);
+diff --git a/ext/punycode.c b/ext/punycode.c
+index 8770cda..48fb439 100644
+--- a/ext/punycode.c
++++ b/ext/punycode.c
+@@ -66,7 +66,7 @@ static VALUE encode(VALUE self, VALUE str)
+   VALUE retv;
+ 
+   str = rb_check_convert_type(str, T_STRING, "String", "to_s");
+-  ustr = stringprep_utf8_to_ucs4(RSTRING(str)->ptr, RSTRING(str)->len, &len);
++  ustr = stringprep_utf8_to_ucs4(RSTRING_PTR(str), RSTRING_LEN(str), &len);
+ 
+   while (1) {
+     buf = realloc(buf, buflen);
+@@ -116,7 +116,7 @@ static VALUE decode(VALUE self, VALUE str)
+ 
+   str = rb_check_convert_type(str, T_STRING, "String", "to_s");
+ 
+-  len = RSTRING(str)->len;
++  len = RSTRING_LEN(str);
+   ustr = malloc(len * sizeof(punycode_uint));
+ 
+   if (ustr == NULL) {
+@@ -124,7 +124,7 @@ static VALUE decode(VALUE self, VALUE str)
+     return Qnil;
+   }
+ 
+-  rc = punycode_decode(RSTRING(str)->len, RSTRING(str)->ptr,
++  rc = punycode_decode(RSTRING_LEN(str), RSTRING_PTR(str),
+                        &len, ustr, NULL);
+ 
+   if (rc != PUNYCODE_SUCCESS) {
+diff --git a/ext/stringprep.c b/ext/stringprep.c
+index f5a59a9..4628e11 100644
+--- a/ext/stringprep.c
++++ b/ext/stringprep.c
+@@ -64,7 +64,7 @@ static VALUE stringprep_internal(VALUE str, const char *profile)
+   VALUE retv;
+ 
+   str = rb_check_convert_type(str, T_STRING, "String", "to_s");
+-  rc = stringprep_profile(RSTRING(str)->ptr, &buf, profile, 0);
++  rc = stringprep_profile(RSTRING_PTR(str), &buf, profile, 0);
+ 
+   if (rc != STRINGPREP_OK) {
+     rb_raise(eStringprepError, "%s (%d)", stringprep_strerror(rc), rc);
+@@ -135,7 +135,7 @@ static VALUE resourceprep(VALUE self, VALUE str)
+ static VALUE with_profile(VALUE self, VALUE str, VALUE profile)
+ {
+   profile = rb_check_convert_type(profile, T_STRING, "String", "to_s");
+-  return stringprep_internal(str, RSTRING(profile)->ptr);
++  return stringprep_internal(str, RSTRING_PTR(profile));
+ }
+ 
+ /*
+@@ -153,7 +153,7 @@ static VALUE nfkc_normalize(VALUE self, VALUE str)
+   VALUE retv;
+ 
+   str = rb_check_convert_type(str, T_STRING, "String", "to_s");
+-  buf = stringprep_utf8_nfkc_normalize(RSTRING(str)->ptr, RSTRING(str)->len);
++  buf = stringprep_utf8_nfkc_normalize(RSTRING_PTR(str), RSTRING_LEN(str));
+ 
+   retv = rb_str_new2(buf);
+   xfree(buf);
+-- 
+1.7.7.6
+


More information about the scm-commits mailing list