decode_www_form_component 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,13 +9,14 @@ decode_uri_changed(VALUE uri, unsigned i)
9
9
  char tmp[3] = {0};
10
10
  int j;
11
11
  char *r;
12
- VALUE ret = rb_str_buf_new(length);
13
- rb_str_cat(ret, u, i+1);
12
+ VALUE ret = rb_usascii_str_new(NULL, length);
13
+ rb_str_resize(ret, 0);
14
+ rb_str_cat(ret, u, i);
14
15
  r = StringValuePtr(ret);
15
- for (j = i; i < length; i++, j++) {
16
+ for (j = i; i < length; i++) {
16
17
  switch (u[i]) {
17
18
  case '+':
18
- r[j] = ' ';
19
+ r[j++] = ' ';
19
20
  break;
20
21
  case '%':
21
22
  if (!ISXDIGIT(u[i+1]) || !ISXDIGIT(u[i+2])) {
@@ -23,11 +24,11 @@ decode_uri_changed(VALUE uri, unsigned i)
23
24
  }
24
25
  tmp[0] = u[i+1];
25
26
  tmp[1] = u[i+2];
26
- r[j] = (char)strtol(tmp, NULL, 16);
27
+ r[j++] = (char)strtol(tmp, NULL, 16);
27
28
  i += 2;
28
29
  break;
29
30
  default:
30
- r[j] = u[i];
31
+ r[j++] = u[i];
31
32
  }
32
33
  }
33
34
  rb_str_resize(ret, j);
@@ -1,7 +1,7 @@
1
1
  require 'decode_www_form_component.so'
2
2
 
3
3
  module DecodeWwwFormComponent
4
- VERSION = '0.1'
4
+ VERSION = '0.2'
5
5
  end
6
6
 
7
7
  module URI
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decode_www_form_component
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: