cgi 0.3.6 → 0.4.2
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/{LICENSE.txt → BSDL} +3 -3
- data/COPYING +56 -0
- data/ext/cgi/escape/escape.c +28 -7
- data/ext/cgi/escape/extconf.rb +5 -1
- data/lib/cgi/cookie.rb +3 -2
- data/lib/cgi/session/pstore.rb +5 -2
- data/lib/cgi/session.rb +1 -1
- data/lib/cgi/util.rb +13 -7
- data/lib/cgi.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2223dc33d62279bcf8cb78f68d8fb46f22c8d9e396243e22d43ded77291dfe5
|
4
|
+
data.tar.gz: 70b263423e005129ac529dd41f59324accedd2cf6fd8c260965286ff0f03a399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d63be598547392b545cabca27ed6f6765ffa9d8e778335118fa29592c36d8276cc68af052db7abe8e2373c8818072523df6e6aaf65393d09c7c5d16600af6cd
|
7
|
+
data.tar.gz: 5a27bb456ab0ecee2e504b737f1b7e8f8e2dd3d56f253fd9c08b5ef42fb145dbc1fbb5e3cec9e98866b19d42aa63d58b4b36affa94a25be9e9f46fa2bc03c942
|
data/{LICENSE.txt → BSDL}
RENAMED
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
5
5
|
are met:
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
11
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
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/cookie.rb
CHANGED
@@ -190,9 +190,10 @@ class CGI
|
|
190
190
|
values ||= ""
|
191
191
|
values = values.split('&').collect{|v| CGI.unescape(v,@@accept_charset) }
|
192
192
|
if cookies.has_key?(name)
|
193
|
-
|
193
|
+
cookies[name].concat(values)
|
194
|
+
else
|
195
|
+
cookies[name] = Cookie.new(name, *values)
|
194
196
|
end
|
195
|
-
cookies[name] = Cookie.new(name, *values)
|
196
197
|
end
|
197
198
|
|
198
199
|
cookies
|
data/lib/cgi/session/pstore.rb
CHANGED
@@ -11,7 +11,10 @@
|
|
11
11
|
# cgi/session.rb for more details on session storage managers.
|
12
12
|
|
13
13
|
require_relative '../session'
|
14
|
-
|
14
|
+
begin
|
15
|
+
require 'pstore'
|
16
|
+
rescue LoadError
|
17
|
+
end
|
15
18
|
|
16
19
|
class CGI
|
17
20
|
class Session
|
@@ -82,7 +85,7 @@ class CGI
|
|
82
85
|
File::unlink path
|
83
86
|
end
|
84
87
|
|
85
|
-
end
|
88
|
+
end if defined?(::PStore)
|
86
89
|
end
|
87
90
|
end
|
88
91
|
# :enddoc:
|
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
|
@@ -178,7 +184,7 @@ module CGI::Util
|
|
178
184
|
def escapeElement(string, *elements)
|
179
185
|
elements = elements[0] if elements[0].kind_of?(Array)
|
180
186
|
unless elements.empty?
|
181
|
-
string.gsub(/<\/?(?:#{elements.join("|")})
|
187
|
+
string.gsub(/<\/?(?:#{elements.join("|")})\b[^<>]*+>?/im) do
|
182
188
|
CGI.escapeHTML($&)
|
183
189
|
end
|
184
190
|
else
|
@@ -198,7 +204,7 @@ module CGI::Util
|
|
198
204
|
def unescapeElement(string, *elements)
|
199
205
|
elements = elements[0] if elements[0].kind_of?(Array)
|
200
206
|
unless elements.empty?
|
201
|
-
string.gsub(/<\/?(?:#{elements.join("|")})(
|
207
|
+
string.gsub(/<\/?(?:#{elements.join("|")})\b(?>[^&]+|&(?![gl]t;)\w+;)*(?:>)?/im) do
|
202
208
|
unescapeHTML($&)
|
203
209
|
end
|
204
210
|
else
|
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.2
|
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: 2025-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Support for the Common Gateway Interface protocol.
|
14
14
|
email:
|
@@ -18,7 +18,8 @@ extensions:
|
|
18
18
|
- ext/cgi/escape/extconf.rb
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
-
|
21
|
+
- BSDL
|
22
|
+
- COPYING
|
22
23
|
- README.md
|
23
24
|
- ext/cgi/escape/depend
|
24
25
|
- ext/cgi/escape/escape.c
|
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
54
55
|
requirements: []
|
55
|
-
rubygems_version: 3.
|
56
|
+
rubygems_version: 3.5.11
|
56
57
|
signing_key:
|
57
58
|
specification_version: 4
|
58
59
|
summary: Support for the Common Gateway Interface protocol.
|