cgi 0.3.6 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/cgi/escape/escape.c +28 -7
- data/ext/cgi/escape/extconf.rb +5 -1
- data/lib/cgi/session.rb +1 -1
- data/lib/cgi/util.rb +11 -5
- data/lib/cgi.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322dda46df05e926c9ec8e57cdc7039b979977445c944901bba03b862b3615bb
|
4
|
+
data.tar.gz: 8284fe91ea3d3c29d7a4febb86d71453dd931cda16c9e6e6d5f56d876c78d596
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e5917d16d0814a8b293f78beec9c15b453b359b6539d435d8e4fb555388be2d4b86a0c96f63233c766638c5717627ed44d013dbcebb99b3a83d19637b0e1055
|
7
|
+
data.tar.gz: 85fa69cdf8c6b19803d598ff5cbeac2787316dede6a677702e7103df050f7f6fa6e25bb61fe215e571c9a425f7dc2e487473a1f9883c0fffd7cb756651dad0df
|
data/ext/cgi/escape/escape.c
CHANGED
@@ -83,7 +83,7 @@ optimized_unescape_html(VALUE str)
|
|
83
83
|
unsigned long charlimit = (strcasecmp(rb_enc_name(enc), "UTF-8") == 0 ? UNICODE_MAX :
|
84
84
|
strcasecmp(rb_enc_name(enc), "ISO-8859-1") == 0 ? 256 :
|
85
85
|
128);
|
86
|
-
long i, len, beg = 0;
|
86
|
+
long i, j, len, beg = 0;
|
87
87
|
size_t clen, plen;
|
88
88
|
int overflow;
|
89
89
|
const char *cstr;
|
@@ -100,6 +100,7 @@ optimized_unescape_html(VALUE str)
|
|
100
100
|
plen = i - beg;
|
101
101
|
if (++i >= len) break;
|
102
102
|
c = (unsigned char)cstr[i];
|
103
|
+
j = i;
|
103
104
|
#define MATCH(s) (len - i >= (int)rb_strlen_lit(s) && \
|
104
105
|
memcmp(&cstr[i], s, rb_strlen_lit(s)) == 0 && \
|
105
106
|
(i += rb_strlen_lit(s) - 1, 1))
|
@@ -112,28 +113,40 @@ optimized_unescape_html(VALUE str)
|
|
112
113
|
else if (MATCH("mp;")) {
|
113
114
|
c = '&';
|
114
115
|
}
|
115
|
-
else
|
116
|
+
else {
|
117
|
+
i = j;
|
118
|
+
continue;
|
119
|
+
}
|
116
120
|
break;
|
117
121
|
case 'q':
|
118
122
|
++i;
|
119
123
|
if (MATCH("uot;")) {
|
120
124
|
c = '"';
|
121
125
|
}
|
122
|
-
else
|
126
|
+
else {
|
127
|
+
i = j;
|
128
|
+
continue;
|
129
|
+
}
|
123
130
|
break;
|
124
131
|
case 'g':
|
125
132
|
++i;
|
126
133
|
if (MATCH("t;")) {
|
127
134
|
c = '>';
|
128
135
|
}
|
129
|
-
else
|
136
|
+
else {
|
137
|
+
i = j;
|
138
|
+
continue;
|
139
|
+
}
|
130
140
|
break;
|
131
141
|
case 'l':
|
132
142
|
++i;
|
133
143
|
if (MATCH("t;")) {
|
134
144
|
c = '<';
|
135
145
|
}
|
136
|
-
else
|
146
|
+
else {
|
147
|
+
i = j;
|
148
|
+
continue;
|
149
|
+
}
|
137
150
|
break;
|
138
151
|
case '#':
|
139
152
|
if (len - ++i >= 2 && ISDIGIT(cstr[i])) {
|
@@ -142,9 +155,15 @@ optimized_unescape_html(VALUE str)
|
|
142
155
|
else if ((cstr[i] == 'x' || cstr[i] == 'X') && len - ++i >= 2 && ISXDIGIT(cstr[i])) {
|
143
156
|
cc = ruby_scan_digits(&cstr[i], len-i, 16, &clen, &overflow);
|
144
157
|
}
|
145
|
-
else
|
158
|
+
else {
|
159
|
+
i = j;
|
160
|
+
continue;
|
161
|
+
}
|
146
162
|
i += clen;
|
147
|
-
if (overflow || cc >= charlimit || cstr[i] != ';')
|
163
|
+
if (overflow || cc >= charlimit || cstr[i] != ';') {
|
164
|
+
i = j;
|
165
|
+
continue;
|
166
|
+
}
|
148
167
|
if (!dest) {
|
149
168
|
dest = rb_str_buf_new(len);
|
150
169
|
}
|
@@ -458,7 +477,9 @@ InitVM_escape(void)
|
|
458
477
|
rb_define_method(rb_mEscape, "escapeHTML", cgiesc_escape_html, 1);
|
459
478
|
rb_define_method(rb_mEscape, "unescapeHTML", cgiesc_unescape_html, 1);
|
460
479
|
rb_define_method(rb_mEscape, "escapeURIComponent", cgiesc_escape_uri_component, 1);
|
480
|
+
rb_define_alias(rb_mEscape, "escape_uri_component", "escapeURIComponent");
|
461
481
|
rb_define_method(rb_mEscape, "unescapeURIComponent", cgiesc_unescape_uri_component, -1);
|
482
|
+
rb_define_alias(rb_mEscape, "unescape_uri_component", "unescapeURIComponent");
|
462
483
|
rb_define_method(rb_mEscape, "escape", cgiesc_escape, 1);
|
463
484
|
rb_define_method(rb_mEscape, "unescape", cgiesc_unescape, -1);
|
464
485
|
rb_prepend_module(rb_mUtil, rb_mEscape);
|
data/ext/cgi/escape/extconf.rb
CHANGED
data/lib/cgi/session.rb
CHANGED
@@ -279,7 +279,7 @@ class CGI
|
|
279
279
|
# fields are surrounded by a <fieldset> tag in HTML 4 generation, which
|
280
280
|
# is _not_ invisible on many browsers; you may wish to disable the
|
281
281
|
# use of fieldsets with code similar to the following
|
282
|
-
# (see
|
282
|
+
# (see https://blade.ruby-lang.org/ruby-list/37805)
|
283
283
|
#
|
284
284
|
# cgi = CGI.new("html4")
|
285
285
|
# class << cgi
|
data/lib/cgi/util.rb
CHANGED
@@ -36,7 +36,7 @@ module CGI::Util
|
|
36
36
|
|
37
37
|
# URL-encode a string following RFC 3986
|
38
38
|
# Space characters (+" "+) are encoded with (+"%20"+)
|
39
|
-
# url_encoded_string = CGI.
|
39
|
+
# url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred")
|
40
40
|
# # => "%27Stop%21%27%20said%20Fred"
|
41
41
|
def escapeURIComponent(string)
|
42
42
|
encoding = string.encoding
|
@@ -46,9 +46,10 @@ module CGI::Util
|
|
46
46
|
end
|
47
47
|
buffer.force_encoding(encoding)
|
48
48
|
end
|
49
|
+
alias escape_uri_component escapeURIComponent
|
49
50
|
|
50
51
|
# URL-decode a string following RFC 3986 with encoding(optional).
|
51
|
-
# string = CGI.
|
52
|
+
# string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
|
52
53
|
# # => "'Stop!'+said Fred"
|
53
54
|
def unescapeURIComponent(string, encoding = @@accept_charset)
|
54
55
|
str = string.b
|
@@ -59,6 +60,8 @@ module CGI::Util
|
|
59
60
|
str.valid_encoding? ? str : str.force_encoding(string.encoding)
|
60
61
|
end
|
61
62
|
|
63
|
+
alias unescape_uri_component unescapeURIComponent
|
64
|
+
|
62
65
|
# The set of special characters and their escaped values
|
63
66
|
TABLE_FOR_ESCAPE_HTML__ = {
|
64
67
|
"'" => ''',
|
@@ -90,9 +93,12 @@ module CGI::Util
|
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
# TruffleRuby runs the pure-Ruby variant faster, do not use the C extension there
|
97
|
+
unless RUBY_ENGINE == 'truffleruby'
|
98
|
+
begin
|
99
|
+
require 'cgi/escape'
|
100
|
+
rescue LoadError
|
101
|
+
end
|
96
102
|
end
|
97
103
|
|
98
104
|
# Unescape a string that has been HTML-escaped
|
data/lib/cgi.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cgi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Support for the Common Gateway Interface protocol.
|
14
14
|
email:
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
|
-
rubygems_version: 3.
|
55
|
+
rubygems_version: 3.5.0.dev
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: Support for the Common Gateway Interface protocol.
|