Skip to content

Commit f69aeb8

Browse files
committedNov 24, 2021
merge some parts of CGI 0.1.1
Fix integer overflow Make use of the check in rb_alloc_tmp_buffer2. When parsing cookies, only decode the values Bump version
1 parent b198562 commit f69aeb8

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed
 

‎ext/cgi/escape/escape.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static VALUE
3636
optimized_escape_html(VALUE str)
3737
{
3838
VALUE vbuf;
39-
char *buf = ALLOCV_N(char, vbuf, RSTRING_LEN(str) * HTML_ESCAPE_MAX_LEN);
39+
typedef char escape_buf[HTML_ESCAPE_MAX_LEN];
40+
char *buf = *ALLOCV_N(escape_buf, vbuf, RSTRING_LEN(str));
4041
const char *cstr = RSTRING_PTR(str);
4142
const char *end = cstr + RSTRING_LEN(str);
4243

‎lib/cgi/cookie.rb

-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def self.parse(raw_cookie)
159159
raw_cookie.split(/;\s?/).each do |pairs|
160160
name, values = pairs.split('=',2)
161161
next unless name and values
162-
name = CGI.unescape(name)
163162
values ||= ""
164163
values = values.split('&').collect{|v| CGI.unescape(v,@@accept_charset) }
165164
if cookies.has_key?(name)

‎lib/cgi/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class CGI
2-
VERSION = "0.1.0"
2+
VERSION = "0.1.0.1"
33
end

‎test/cgi/test_cgi_cookie.rb

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def test_cgi_cookie_parse
101101
end
102102
end
103103

104+
def test_cgi_cookie_parse_not_decode_name
105+
cookie_str = "%66oo=baz;foo=bar"
106+
cookies = CGI::Cookie.parse(cookie_str)
107+
assert_equal({"%66oo" => ["baz"], "foo" => ["bar"]}, cookies)
108+
end
104109

105110
def test_cgi_cookie_arrayinterface
106111
cookie = CGI::Cookie.new('name1', 'a', 'b', 'c')

‎version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
33
#define RUBY_VERSION_TEENY 5
44
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
5-
#define RUBY_PATCHLEVEL 202
5+
#define RUBY_PATCHLEVEL 203
66

77
#define RUBY_RELEASE_YEAR 2021
88
#define RUBY_RELEASE_MONTH 11

0 commit comments

Comments
 (0)
Failed to load comments.