curl_escape 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/curl_escape/curl_escape.c +15 -11
- data/ext/curl_escape/extconf.rb +0 -2
- data/lib/curl_escape/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cc7b71d0852a4742c04075e57c59a9548afab18
|
4
|
+
data.tar.gz: 90d77f2ba82fb50bb2760750a425eccc05f9aaa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644f12380a3198872682c5d4bc0a42449a2e06066beb01909ce13adb749415090954142a9986e30fa2fcb0fe0bde37e3e6af7771ce4ac0a1f121ed2edeb682cc
|
7
|
+
data.tar.gz: 5892f35b9904110e2681994aa724b2248cd331dba4bce1feb3fb173ab484c0d40a60ebdb92d3ba4591c2075b4a9e1b8efb6a992fac4e09aebf7a89377ae2b9e4
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#include <ruby.h>
|
4
4
|
|
5
5
|
VALUE ruby_curl_escape(VALUE self, VALUE str) {
|
6
|
-
int
|
6
|
+
int cnt;
|
7
7
|
VALUE output;
|
8
8
|
|
9
9
|
static CURL *curl;
|
@@ -14,23 +14,27 @@ VALUE ruby_curl_escape(VALUE self, VALUE str) {
|
|
14
14
|
char *cStr = StringValueCStr(str);
|
15
15
|
char *cOutput = curl_easy_escape(curl, cStr, strlen(cStr));
|
16
16
|
|
17
|
+
int pos = 0;
|
18
|
+
char buf[strlen(cOutput) * 3];
|
19
|
+
|
17
20
|
if (cOutput) {
|
18
21
|
for (cnt = 0; *(cOutput + cnt) != '\0'; cnt++) {
|
19
22
|
if (strncmp(cOutput + cnt, "%20", 3) == 0) {
|
20
|
-
|
21
|
-
|
22
|
-
memmove(cOutput + cnt + 1, cOutput + cnt + 3, rest);
|
23
|
-
*(cOutput + cnt + 1 + rest) = '\0';
|
23
|
+
buf[pos] = '+';
|
24
|
+
cnt += 2;
|
24
25
|
} else if (*(cOutput + cnt) == '~') {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
buf[pos] = '%';
|
27
|
+
buf[pos+1] = '7';
|
28
|
+
buf[pos+2] = 'E';
|
29
|
+
pos += 2;
|
30
|
+
} else {
|
31
|
+
buf[pos] = *(cOutput + cnt);
|
30
32
|
}
|
33
|
+
pos++;
|
31
34
|
}
|
35
|
+
buf[pos++] = '\0';
|
32
36
|
|
33
|
-
output = rb_str_new2(
|
37
|
+
output = rb_str_new2(buf);
|
34
38
|
curl_free(cOutput);
|
35
39
|
return output;
|
36
40
|
} else {
|
data/ext/curl_escape/extconf.rb
CHANGED
data/lib/curl_escape/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curl_escape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|