idn-ruby 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f2570c09d706246f8a0ca7371e0dfa865024e5d2d4e0749109c02ae22e19f2e7
4
+ data.tar.gz: 31864ba33c666b02dc29f515602ba75b46d712246e06e4e9de9f29f8215c1071
5
+ SHA512:
6
+ metadata.gz: 6e0c1bb1b1bdd659a7d2abef20362053758121195ec42aec3f6a646db8a20e876e36438666aac0a626ea3f70c8f3aaee4db6f478d844a674311d1f4f286987de
7
+ data.tar.gz: 42ebf3aed3ffb81249a01106a205b47d4488dbc16b312f2872dfff4deea857f54ea3788924a2bc6048abab6ae51808018179299367276cbbd7440c011805737e
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ Changes with IDN 0.1.2 (2021-06-10)
2
+
3
+ * add missing includes
4
+ * fix default encoding to use utf8
5
+
6
+ Changes with IDN 0.1.1 [yanked] (2021-06-09)
7
+
8
+ * Use xfree() only with memory allocated with xmalloc()/xrealloc(). Free
9
+ IDN-allocated memory with idn_free()
10
+
1
11
  Changes with IDN 0.1.0 (2011-03-31)
2
12
 
3
13
  * Fix compilation errors in ruby 1.9.2p0 (2010-08-18 revision 29036).
@@ -1,6 +1,6 @@
1
- == LibIDN Ruby Bindings
1
+ # LibIDN Ruby Bindings
2
2
 
3
- Version 0.1.0
3
+ Version 0.1.2
4
4
 
5
5
  Ruby Bindings for the GNU LibIDN library, an implementation of the
6
6
  Stringprep, Punycode and IDNA specifications defined by the IETF
@@ -14,113 +14,141 @@ to and from the ACE encoded form.
14
14
  The latest version of the LibIDN Ruby Bindings project and its
15
15
  documentation can always be found at
16
16
 
17
+ * https://github.com/deepfryed/idn-ruby
18
+
19
+ The original version can be found at,
20
+
17
21
  * http://rubyforge.org/projects/idn
18
22
 
19
23
  See the CHANGES file for detailed information on the changes of every
20
24
  released version.
21
25
 
22
26
 
23
- === Requirements
27
+ ### Requirements
24
28
 
25
- * GNU LibIDN[http://www.gnu.org/software/libidn/] Library
29
+ * [GNU LibIDN](http://www.gnu.org/software/libidn/) Library
26
30
 
27
- * Rake[http://rubyforge.org/projects/rake] to run the tests and generate
31
+ * [Rake](http://rubyforge.org/projects/rake) to run the tests and generate
28
32
  the documentation
29
33
 
30
- * RubyGems[http://docs.rubygems.org/] to produce a Gem package
34
+ * [RubyGems](http://docs.rubygems.org/) to produce a Gem package
31
35
 
32
36
  * Ruby 1.9.1 or above. Patches welcome to make this work in 1.8.7
33
37
 
34
38
 
35
- === Installation
39
+ ### Installation
40
+
41
+ You need GNU LibIDN installed first.
42
+
43
+ * On MacOS you can install it with `brew install libidn`
44
+ * On Debian flavours of Linux `apt-get install libidn11-dev`
36
45
 
37
46
  You can easily install the LibIDN Ruby Bindings by following one of the
38
47
  ways outlined below:
39
48
 
40
- ==== Automatic installation and management with RubyGems
49
+ #### Automatic installation and management with RubyGems
41
50
 
42
51
  Simply invoke the standard RubyGems commands (install, update, ...),
43
52
  for example:
44
53
 
45
- % gem install --remote --test idn
54
+ ```bash
55
+ gem install --remote --test idn
56
+ ```
46
57
 
47
58
  or if the GNU LibIDN library can only be found in a non-standard location
48
59
 
49
- % gem install --remote --test idn -- \
50
- --with-idn-dir=/path/to/non/standard/location
60
+ ```bash
61
+ gem install --remote --test idn -- \
62
+ --with-idn-dir=/path/to/non/standard/location
63
+ ```
51
64
 
52
65
  or in an even more complex setup
53
66
 
54
- % gem install --remote --test idn -- \
55
- --with-idn-lib=/path/to/non/standard/location/lib \
56
- --with-idn-include=/path/to/non/standard/location/include
67
+ ```bash
68
+ gem install --remote --test idn -- \
69
+ --with-idn-lib=/path/to/non/standard/location/lib \
70
+ --with-idn-include=/path/to/non/standard/location/include
71
+ ```
57
72
 
58
- ==== Semi-automatic installation with Rake
73
+ #### Semi-automatic installation with Rake
59
74
 
60
75
  If you are not able to or don't want to use RubyGems you can simply
61
76
  download the latest release and install it with the help of Rake:
62
77
 
63
- % tar -xvzf idn-x.x.x.tar.gz
64
- % cd idn-x.x.x
78
+ ```bash
79
+ tar -xvzf idn-x.x.x.tar.gz
80
+ cd idn-x.x.x
65
81
 
66
- % rake install
82
+ rake install
83
+ ```
67
84
 
68
85
  or if the GNU LibIDN library can only be found in a non-standard location
69
86
 
70
- % rake install IDN_DIR=/path/to/non/standard/location
87
+ ```bash
88
+ rake install IDN_DIR=/path/to/non/standard/location
89
+ ```
71
90
 
72
91
  You can also run the tests or generate the documentation; just call Rake
73
92
  with the '--tasks' parameter to get an overview of the available tasks:
74
93
 
75
- % rake --tasks
94
+ ```bash
95
+ rake --tasks
96
+ ```
76
97
 
77
- ==== Manual installation with extconf.rb
98
+ #### Manual installation with extconf.rb
78
99
 
79
100
  If you are not able to or don't want to use even Rake then you will have to
80
101
  do a little bit more work by yourself:
81
102
 
82
- % tar -xvzf idn-x.x.x.tar.gz
83
- % cd idn-x.x.x/ext
103
+ ```bash
104
+ tar -xvzf idn-x.x.x.tar.gz
105
+ cd idn-x.x.x/ext
84
106
 
85
- % ruby extconf.rb
107
+ ruby extconf.rb
108
+ ```
86
109
 
87
110
  or if the GNU LibIDN library can only be found in a non-standard location
88
111
 
89
- % ruby extconf.rb \
90
- --with-idn-dir=/path/to/non/standard/location
112
+ ```bash
113
+ ruby extconf.rb \
114
+ --with-idn-dir=/path/to/non/standard/location
115
+ ```
91
116
 
92
117
  or in an even more complex setup
93
118
 
94
- % ruby extconf.rb \
95
- --with-idn-lib=/path/to/non/standard/location/lib \
96
- --with-idn-include=/path/to/non/standard/location/include
119
+ ```bash
120
+ ruby extconf.rb \
121
+ --with-idn-lib=/path/to/non/standard/location/lib \
122
+ --with-idn-include=/path/to/non/standard/location/include
123
+ ```
97
124
 
98
125
  and finally
99
126
 
100
- % make
101
- % sudo make install
127
+ ```bash
128
+ make
129
+ sudo make install
130
+ ```
102
131
 
103
132
 
104
- === Documentation
133
+ ### Documentation
105
134
 
106
135
  The complete documentation is available online at
107
136
 
108
- * http://idn.rubyforge.org/docs
109
-
110
- See also the section on 'Semi-automatic installation with Rake' above for
111
- some details on how to generate the documentation by yourself.
137
+ * http://rubydoc.info/github/deepfryed/idn-ruby/master/frames
112
138
 
113
- ==== Example usage
139
+ #### Example usage
114
140
 
115
- require 'idn'
116
- include IDN
141
+ ```ruby
142
+ require 'idn'
143
+ include IDN
117
144
 
118
- puts 'Idna.toUnicode: ' + Idna.toUnicode('xn--rksmrgs-5wao1o.josefsson.org')
119
- puts 'Punycode.decode: ' + Punycode.decode('egbpdaj6bu4bxfgehfvwxn')
120
- puts 'Stringprep.with_profile: ' + Stringprep.with_profile('FOO', 'Nameprep')
145
+ puts 'Idna.toUnicode: ' + Idna.toUnicode('xn--rksmrgs-5wao1o.josefsson.org')
146
+ puts 'Punycode.decode: ' + Punycode.decode('egbpdaj6bu4bxfgehfvwxn')
147
+ puts 'Stringprep.with_profile: ' + Stringprep.with_profile('FOO', 'Nameprep')
148
+ ```
121
149
 
122
150
 
123
- === References
151
+ ### References
124
152
 
125
153
  [GNU LibIDN]
126
154
  An implementation of the Stringprep, Punycode and IDNA specifications
@@ -156,19 +184,20 @@ some details on how to generate the documentation by yourself.
156
184
  * http://www.ietf.org/rfc/rfc3492.txt
157
185
 
158
186
 
159
- === Questions, comments, patches?
187
+ ### Questions, comments, patches?
160
188
 
161
189
  If you have any questions, comments or feature requests or if you want
162
190
  to submit a bug report or provide a patch, then have a look at the project
163
191
  website at
164
192
 
165
- * http://rubyforge.org/projects/idn
193
+ * https://github.com/deepfryed/idn-ruby
194
+ * http://rubyforge.org/projects/idn (original)
166
195
 
167
196
  For other information, feel free to ask on the idn-discuss at rubyforge.org
168
197
  mailing list.
169
198
 
170
199
 
171
- === Copyright & License
200
+ ### Copyright & License
172
201
 
173
202
  Copyright (c) 2005-2006 Erik Abele. 2011 Bharanee Rathna. All rights reserved.
174
203
 
data/Rakefile CHANGED
@@ -2,8 +2,6 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
- require 'rake/rdoctask'
6
- require 'rake/extensiontask'
7
5
 
8
6
  CLEAN << FileList[ 'ext/Makefile', 'ext/*.so', 'ext/*.o' ]
9
7
 
@@ -36,18 +34,10 @@ end
36
34
 
37
35
  Jeweler::GemcutterTasks.new
38
36
 
39
- Rake::ExtensionTask.new do |ext|
40
- ext.name = 'idn'
41
- ext.ext_dir = 'ext'
42
- ext.lib_dir = 'ext'
43
- end
44
-
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
- rdoc.rdoc_dir = 'rdoc'
48
- rdoc.title = "idn-ruby #{version}"
49
- rdoc.rdoc_files.include('README*')
50
- rdoc.rdoc_files.include('lib/**/*.rb')
37
+ task :compile do
38
+ Dir.chdir('ext') do
39
+ system('ruby extconf.rb && make') or raise 'failed to compile extension'
40
+ end
51
41
  end
52
42
 
53
43
  Rake::TestTask.new(:test) do |test|
@@ -56,5 +46,5 @@ Rake::TestTask.new(:test) do |test|
56
46
  test.verbose = true
57
47
  end
58
48
 
59
- task :test => [ :compile, :check_dependencies ]
49
+ task :test => [ :compile ]
60
50
  task :default => :test
data/ext/idna.c CHANGED
@@ -23,6 +23,7 @@
23
23
  #include <ruby.h>
24
24
  #include <idna.h>
25
25
  #include "idn.h"
26
+ #include "idn-free.h"
26
27
 
27
28
  /*
28
29
  * Document-class: IDN::Idna
@@ -88,13 +89,13 @@ static VALUE toASCII(int argc, VALUE argv[], VALUE self)
88
89
  rc = idna_to_ascii_8z(RSTRING_PTR(str), &buf, flags);
89
90
 
90
91
  if (rc != IDNA_SUCCESS) {
91
- xfree(buf);
92
+ idn_free(buf);
92
93
  rb_raise(eIdnaError, "%s (%d)", idna_strerror(rc), rc);
93
94
  return Qnil;
94
95
  }
95
96
 
96
- retv = rb_str_new2(buf);
97
- xfree(buf);
97
+ retv = rb_utf8_str_new_cstr(buf);
98
+ idn_free(buf);
98
99
  return retv;
99
100
  }
100
101
 
@@ -128,13 +129,13 @@ static VALUE toUnicode(int argc, VALUE argv[], VALUE self)
128
129
  rc = idna_to_unicode_8z8z(RSTRING_PTR(str), &buf, flags);
129
130
 
130
131
  if (rc != IDNA_SUCCESS) {
131
- xfree(buf);
132
+ idn_free(buf);
132
133
  rb_raise(eIdnaError, "%s (%d)", idna_strerror(rc), rc);
133
134
  return Qnil;
134
135
  }
135
136
 
136
137
  retv = rb_enc_str_new(buf, strlen(buf), rb_utf8_encoding());
137
- xfree(buf);
138
+ idn_free(buf);
138
139
  return retv;
139
140
  }
140
141
 
@@ -153,7 +154,7 @@ void init_idna(void)
153
154
  eIdnaError = rb_define_class_under(mIdna, "IdnaError", eIDNError);
154
155
 
155
156
  rb_define_const(mIdna, "ACE_PREFIX",
156
- rb_str_new2(IDNA_ACE_PREFIX));
157
+ rb_utf8_str_new_cstr(IDNA_ACE_PREFIX));
157
158
  rb_define_const(mIdna, "ALLOW_UNASSIGNED",
158
159
  INT2FIX(IDNA_ALLOW_UNASSIGNED));
159
160
  rb_define_const(mIdna, "USE_STD3_ASCII_RULES",
data/ext/punycode.c CHANGED
@@ -25,6 +25,7 @@
25
25
  #include <stringprep.h>
26
26
  #include <punycode.h>
27
27
  #include "idn.h"
28
+ #include "idn-free.h"
28
29
 
29
30
  /*
30
31
  * Document-class: IDN::Punycode
@@ -69,10 +70,10 @@ static VALUE encode(VALUE self, VALUE str)
69
70
  ustr = stringprep_utf8_to_ucs4(RSTRING_PTR(str), RSTRING_LEN(str), &len);
70
71
 
71
72
  while (1) {
72
- buf = realloc(buf, buflen);
73
+ buf = xrealloc(buf, buflen);
73
74
 
74
75
  if (buf == NULL) {
75
- xfree(ustr);
76
+ idn_free(ustr);
76
77
  rb_raise(rb_eNoMemError, "cannot allocate memory (%d bytes)", (uint32_t)buflen);
77
78
  return Qnil;
78
79
  }
@@ -84,7 +85,7 @@ static VALUE encode(VALUE self, VALUE str)
84
85
  } else if (rc == PUNYCODE_BIG_OUTPUT) {
85
86
  buflen += 0x100;
86
87
  } else {
87
- xfree(ustr);
88
+ idn_free(ustr);
88
89
  xfree(buf);
89
90
  rb_raise(ePunycodeError, "%s (%d)", punycode_strerror(rc), rc);
90
91
  return Qnil;
@@ -92,7 +93,7 @@ static VALUE encode(VALUE self, VALUE str)
92
93
  }
93
94
 
94
95
  retv = rb_str_new(buf, buflen);
95
- xfree(ustr);
96
+ idn_free(ustr);
96
97
  xfree(buf);
97
98
  return retv;
98
99
  }
@@ -117,7 +118,7 @@ static VALUE decode(VALUE self, VALUE str)
117
118
  str = rb_check_convert_type(str, T_STRING, "String", "to_s");
118
119
 
119
120
  len = RSTRING_LEN(str);
120
- ustr = malloc(len * sizeof(punycode_uint));
121
+ ustr = xmalloc(len * sizeof(punycode_uint));
121
122
 
122
123
  if (ustr == NULL) {
123
124
  rb_raise(rb_eNoMemError, "cannot allocate memory (%d bytes)", (uint32_t)len);
@@ -136,7 +137,7 @@ static VALUE decode(VALUE self, VALUE str)
136
137
  buf = stringprep_ucs4_to_utf8(ustr, len, NULL, &len);
137
138
  retv = rb_enc_str_new(buf, len, rb_utf8_encoding());
138
139
  xfree(ustr);
139
- xfree(buf);
140
+ idn_free(buf);
140
141
  return retv;
141
142
  }
142
143
 
data/ext/stringprep.c CHANGED
@@ -24,6 +24,7 @@
24
24
  #include <ruby.h>
25
25
  #include <stringprep.h>
26
26
  #include "idn.h"
27
+ #include "idn-free.h"
27
28
 
28
29
  /*
29
30
  * Document-class: IDN::Stringprep
@@ -71,8 +72,8 @@ static VALUE stringprep_internal(VALUE str, const char *profile)
71
72
  return Qnil;
72
73
  }
73
74
 
74
- retv = rb_str_new2(buf);
75
- xfree(buf);
75
+ retv = rb_utf8_str_new_cstr(buf);
76
+ idn_free(buf);
76
77
  return retv;
77
78
  }
78
79
 
@@ -155,8 +156,8 @@ static VALUE nfkc_normalize(VALUE self, VALUE str)
155
156
  str = rb_check_convert_type(str, T_STRING, "String", "to_s");
156
157
  buf = stringprep_utf8_nfkc_normalize(RSTRING_PTR(str), RSTRING_LEN(str));
157
158
 
158
- retv = rb_str_new2(buf);
159
- xfree(buf);
159
+ retv = rb_utf8_str_new_cstr(buf);
160
+ idn_free(buf);
160
161
  return retv;
161
162
  }
162
163
 
metadata CHANGED
@@ -1,82 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: idn-ruby
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Erik Abele
13
8
  - Bharanee Rathna
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-05-31 00:00:00 +10:00
19
- default_executable:
12
+ date: 2021-06-10 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: "\n Ruby Bindings for the GNU LibIDN library, an implementation of the\n Stringprep, Punycode and IDNA specifications defined by the IETF\n Internationalized Domain Names (IDN) working group.\n\n Included are the most important parts of the Stringprep, Punycode\n and IDNA APIs like performing Stringprep processings, encoding to\n and decoding from Punycode strings and converting entire domain names\n to and from the ACE encoded form.\n "
14
+ description: "\n Ruby Bindings for the GNU LibIDN library, an implementation of
15
+ the\n Stringprep, Punycode and IDNA specifications defined by the IETF\n Internationalized
16
+ Domain Names (IDN) working group.\n\n Included are the most important parts of
17
+ the Stringprep, Punycode\n and IDNA APIs like performing Stringprep processings,
18
+ encoding to\n and decoding from Punycode strings and converting entire domain
19
+ names\n to and from the ACE encoded form.\n "
23
20
  email: deepfryed@gmail.com
24
21
  executables: []
25
-
26
- extensions:
22
+ extensions:
27
23
  - ext/extconf.rb
28
- extra_rdoc_files:
24
+ extra_rdoc_files:
29
25
  - LICENSE
30
- - README
31
- files:
26
+ - README.md
27
+ files:
32
28
  - CHANGES
33
29
  - LICENSE
34
30
  - NOTICE
35
- - README
31
+ - README.md
36
32
  - Rakefile
33
+ - ext/extconf.rb
37
34
  - ext/idn.c
38
35
  - ext/idn.h
39
36
  - ext/idna.c
40
37
  - ext/punycode.c
41
38
  - ext/stringprep.c
42
- - test/ts_IDN.rb
39
+ - test/tc_Idna.rb
43
40
  - test/tc_Punycode.rb
44
41
  - test/tc_Stringprep.rb
45
- - test/tc_Idna.rb
46
- - ext/extconf.rb
47
- has_rdoc: true
42
+ - test/ts_IDN.rb
48
43
  homepage: http://github.com/deepfryed/idn-ruby
49
44
  licenses: []
50
-
45
+ metadata: {}
51
46
  post_install_message:
52
47
  rdoc_options: []
53
-
54
- require_paths:
48
+ require_paths:
55
49
  - lib
56
- required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
59
52
  - - ">="
60
- - !ruby/object:Gem::Version
61
- segments:
62
- - 0
63
- version: "0"
64
- required_rubygems_version: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
67
57
  - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
72
60
  requirements: []
73
-
74
61
  rubyforge_project:
75
- rubygems_version: 1.3.7
62
+ rubygems_version: 2.7.6
76
63
  signing_key:
77
64
  specification_version: 3
78
65
  summary: LibIDN Ruby Bindings.
79
- test_files:
66
+ test_files:
80
67
  - test/ts_IDN.rb
81
68
  - test/tc_Punycode.rb
82
69
  - test/tc_Stringprep.rb