cgi 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91a0df1762833f2d7c503deccc1e86b6cffa58d0d6d62b2ad9e7f23028e64814
4
- data.tar.gz: 976bd5f43d64516971518aa8ebf148926cf0d3551c5cade9e6ca00c4029dee02
3
+ metadata.gz: 322dda46df05e926c9ec8e57cdc7039b979977445c944901bba03b862b3615bb
4
+ data.tar.gz: 8284fe91ea3d3c29d7a4febb86d71453dd931cda16c9e6e6d5f56d876c78d596
5
5
  SHA512:
6
- metadata.gz: 9a658383c76a8565b93331ed42d8c654b437357cc0218f22a8390f8e32180dcd99a4e8ff398e46d80b7d7d0ed9f0e44100a8b842bb9cbfd3afce7fda878f7281
7
- data.tar.gz: 6915a86235360d47c6ed2cf3c53232425675dbd551829c59aff8190731e298eec6d81fc7846424fd5fa3cd5b75624199ee1c85fff2fcefc147facb901d8e1be3
6
+ metadata.gz: 8e5917d16d0814a8b293f78beec9c15b453b359b6539d435d8e4fb555388be2d4b86a0c96f63233c766638c5717627ed44d013dbcebb99b3a83d19637b0e1055
7
+ data.tar.gz: 85fa69cdf8c6b19803d598ff5cbeac2787316dede6a677702e7103df050f7f6fa6e25bb61fe215e571c9a425f7dc2e487473a1f9883c0fffd7cb756651dad0df
@@ -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 continue;
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 continue;
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 continue;
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 continue;
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 continue;
158
+ else {
159
+ i = j;
160
+ continue;
161
+ }
146
162
  i += clen;
147
- if (overflow || cc >= charlimit || cstr[i] != ';') continue;
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/lib/cgi/util.rb CHANGED
@@ -46,6 +46,7 @@ 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
52
  # string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
@@ -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
  "'" => '&#39;',
data/lib/cgi.rb CHANGED
@@ -288,7 +288,7 @@
288
288
  #
289
289
 
290
290
  class CGI
291
- VERSION = "0.4.0"
291
+ VERSION = "0.4.1"
292
292
  end
293
293
 
294
294
  require 'cgi/core'
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.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: 2023-11-07 00:00:00.000000000 Z
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: