ox 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ox might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 082093a98968b620e01ba43e96933e0f3710e1fa
4
- data.tar.gz: 9322b6eaa676a1c5f43838fa414199e7f9586191
3
+ metadata.gz: 7e0f1c9717a0c2a666b6131188f72dcb26b88230
4
+ data.tar.gz: 93edf8cebd1ef9390ee531b957aa2369b4542a92
5
5
  SHA512:
6
- metadata.gz: 2f4de79cc51b46e8767b754b87ba2ba7d48e2d0f7bbe4f9997070ca5f9417db978fc01f64e1781e3a4aa54277e3a2335cfe533101a0f15c70e9cf4ece028047a
7
- data.tar.gz: 312228d635f3765efe2a11f46e9a1b57c20ca7fdf1e55f0f6996d11252e1cedca3dfe0efa4e594bb2391560519936714d101e8b9e66ea66c9fae3a902ee21b2e
6
+ metadata.gz: 7f2a045152966f88e3ed61aa5804810e3584afc8b05ba129b627c86e7343d9263b95bf39531158bed3d349e8b7dfc2cc7a1f58e7fe2023b53ecd004756e5d345
7
+ data.tar.gz: cf8ab5d25d451ffaf01b8029f72c41bfdb521637189ed3df4a60e7e4ebd566ce8ada66bb397149aa60e9ca9958cf5a0553bb5616c42add5f418b8d4fc8ef7b3f
data/README.md CHANGED
@@ -34,9 +34,9 @@ A fast XML parser and Object marshaller as a Ruby gem.
34
34
 
35
35
  ## <a name="release">Release Notes</a>
36
36
 
37
- ### Release 2.0.4
37
+ ### Release 2.0.5
38
38
 
39
- - Fixed SAX parser handling of &#nnnn; encoded characters.
39
+ - Better support for special character encoding with 1.8.7.
40
40
 
41
41
  ## <a name="description">Description</a>
42
42
 
data/ext/ox/encode.h ADDED
@@ -0,0 +1,51 @@
1
+ /* encode.h
2
+ * Copyright (c) 2011, Peter Ohler
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ *
8
+ * - Redistributions of source code must retain the above copyright notice, this
9
+ * list of conditions and the following disclaimer.
10
+ *
11
+ * - Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * - Neither the name of Peter Ohler nor the names of its contributors may be
16
+ * used to endorse or promote products derived from this software without
17
+ * specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ */
30
+
31
+ #ifndef __OX_ENCODE_H__
32
+ #define __OX_ENCODE_H__
33
+
34
+ #include "ruby.h"
35
+ #if HAS_ENCODING_SUPPORT
36
+ #include "ruby/encoding.h"
37
+ #endif
38
+
39
+ static inline VALUE
40
+ ox_encode(VALUE rstr) {
41
+ #if HAS_ENCODING_SUPPORT
42
+ rb_enc_associate(rstr, ox_utf8_encoding);
43
+ #else
44
+ if (Qnil != ox_utf8_encoding) {
45
+ rstr = rb_funcall(ox_utf8_encoding, ox_iconv_id, 1, rstr);
46
+ }
47
+ #endif
48
+ return rstr;
49
+ }
50
+
51
+ #endif /* __OX_ENCODE_H__ */
data/ext/ox/sax.c CHANGED
@@ -62,6 +62,8 @@
62
62
  #define EL_MISMATCH "Start End Mismatch: "
63
63
  #define INV_ELEMENT "Invalid Element: "
64
64
 
65
+ #define UTF8_STR "UTF-8"
66
+
65
67
  static void sax_drive_init(SaxDrive dr, VALUE handler, VALUE io, SaxOptions options);
66
68
  static void parse(SaxDrive dr);
67
69
  // All read functions should return the next character after the 'thing' that was read and leave dr->cur one after that.
@@ -173,6 +175,8 @@ sax_drive_init(SaxDrive dr, VALUE handler, VALUE io, SaxOptions options) {
173
175
  } else {
174
176
  dr->encoding = rb_str_new2(ox_default_options.encoding);
175
177
  }
178
+ #else
179
+ dr->encoding = 0;
176
180
  #endif
177
181
  }
178
182
 
@@ -216,6 +220,8 @@ skipBOM(SaxDrive dr) {
216
220
  dr->encoding = ox_utf8_encoding;
217
221
  #elif HAS_PRIVATE_ENCODING
218
222
  dr->encoding = ox_utf8_encoding;
223
+ #else
224
+ dr->encoding = UTF8_STR;
219
225
  #endif
220
226
  c = buf_get(&dr->buf);
221
227
  } else {
@@ -987,6 +993,8 @@ read_attrs(SaxDrive dr, char c, char termc, char term2, int is_xml, int eq_req)
987
993
  dr->encoding = rb_enc_find(dr->buf.str);
988
994
  #elif HAS_PRIVATE_ENCODING
989
995
  dr->encoding = rb_str_new2(dr->buf.str);
996
+ #else
997
+ dr->encoding = dr->buf.str;
990
998
  #endif
991
999
  is_encoding = 0;
992
1000
  }
@@ -1211,6 +1219,12 @@ ox_sax_collapse_special(SaxDrive dr, char *str, int line, int col) {
1211
1219
  } else if (Qnil == dr->encoding) {
1212
1220
  dr->encoding = ox_utf8_encoding;
1213
1221
  b = ox_ucs_to_utf8_chars(b, u);
1222
+ #else
1223
+ } else if (0 == dr->encoding) {
1224
+ dr->encoding = UTF8_STR;
1225
+ b = ox_ucs_to_utf8_chars(b, u);
1226
+ } else if (0 == strcasecmp(UTF8_STR, dr->encoding)) {
1227
+ b = ox_ucs_to_utf8_chars(b, u);
1214
1228
  #endif
1215
1229
  } else {
1216
1230
  ox_sax_drive_error(dr, NO_TERM "Invalid encoding, need UTF-8 encoding to parse &#nnnn; character sequences.");
data/ext/ox/sax.h CHANGED
@@ -55,6 +55,8 @@ typedef struct _SaxDrive {
55
55
  rb_encoding *encoding;
56
56
  #elif HAS_PRIVATE_ENCODING
57
57
  VALUE encoding;
58
+ #else
59
+ const char *encoding;
58
60
  #endif
59
61
  } *SaxDrive;
60
62
 
data/lib/ox/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.0.4'
4
+ VERSION = '2.0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2013-07-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "A fast XML parser and object serializer that uses only standard C lib.\n
14
14
  \ \nOptimized XML (Ox), as the name implies was written to provide speed
@@ -39,6 +39,7 @@ files:
39
39
  - ext/ox/base64.h
40
40
  - ext/ox/cache.h
41
41
  - ext/ox/cache8.h
42
+ - ext/ox/encode.h
42
43
  - ext/ox/err.h
43
44
  - ext/ox/helper.h
44
45
  - ext/ox/ox.h