7#define lower_hexdigits (ruby_hexdigits+0)
8#define upper_hexdigits (ruby_hexdigits+16)
9#define char_to_number(c) ruby_digit36_to_number_table[(unsigned char)(c)]
11static VALUE rb_cCGI, rb_mUtil, rb_mEscape;
12static ID id_accept_charset;
14#define HTML_ESCAPE_MAX_LEN 6
19} html_escape_table[UCHAR_MAX+1] = {
20#define HTML_ESCAPE(c, str) [c] = {rb_strlen_lit(str), str}
46 const unsigned char c = *cstr++;
60 preserve_original_state(
str, escaped);
87 for (i = 0; i <
len; i++) {
90 if (c !=
'&')
continue;
92 if (++i >=
len)
break;
93 c = (
unsigned char)cstr[i];
94#define MATCH(s) (len - i >= (int)rb_strlen_lit(s) && \
95 memcmp(&cstr[i], s, rb_strlen_lit(s)) == 0 && \
96 (i += rb_strlen_lit(s) - 1, 1))
103 else if (
MATCH(
"mp;")) {
133 else if ((cstr[i] ==
'x' || cstr[i] ==
'X') &&
len - ++i >= 2 &&
ISXDIGIT(cstr[i])) {
138 if (overflow || cc >= charlimit || cstr[i] !=
';')
continue;
143 if (charlimit > 256) {
147 c = (
unsigned char)cc;
166 preserve_original_state(
str, dest);
175url_unreserved_char(
unsigned char c)
178 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
179 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
180 case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
181 case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
182 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
183 case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
184 case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
185 case '-':
case '.':
case '_':
case '~':
196 long i,
len, beg = 0;
204 for (i = 0; i <
len; ++i) {
205 const unsigned char c = (
unsigned char)cstr[i];
206 if (!url_unreserved_char(c)) {
227 preserve_original_state(
str, dest);
238 long i,
len, beg = 0;
247 for (i = 0; i <
len; ++i) {
249 const char c = cstr[i];
252 if (i + 3 >
len)
break;
279 preserve_original_state(
str, dest);
287 if (origenc != encidx) {
311 return optimized_escape_html(
str);
331 return optimized_unescape_html(
str);
351 return optimized_escape(
str);
382 return optimized_unescape(
str, enc);
392#ifdef HAVE_RB_EXT_RACTOR_SAFE
396 id_accept_charset = rb_intern_const(
"@@accept_charset");
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
int rb_enc_get_index(VALUE obj)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
rb_encoding * rb_enc_get(VALUE obj)
int rb_enc_to_index(rb_encoding *enc)
rb_encoding * rb_to_encoding(VALUE enc)
VALUE rb_enc_associate_index(VALUE obj, int idx)
const signed char ruby_digit36_to_number_table[]
#define HTML_ESCAPE(c, str)
char str[HTML_ESCAPE_MAX_LEN+1]
const char ruby_hexdigits[]
unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow)
#define HTML_ESCAPE_MAX_LEN
#define char_to_number(c)
#define RSTRING_LEN(string)
#define RSTRING_PTR(string)
void rb_extend_object(VALUE obj, VALUE module)
Extend the object with the module.
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
void rb_prepend_module(VALUE klass, VALUE module)
VALUE rb_define_module_under(VALUE outer, const char *name)
VALUE rb_cObject
Object class.
#define rb_enc_mbcput(c, buf, enc)
#define ENC_CODERANGE_CLEAN_P(cr)
#define rb_enc_str_asciicompat_p(str)
int rb_enc_str_coderange(VALUE)
#define ENC_CODERANGE(obj)
#define ENC_CODERANGE_UNKNOWN
#define ENC_CODERANGE_SET(obj, cr)
VALUE rb_call_super(int, const VALUE *)
void rb_ext_ractor_safe(bool flag)
#define rb_str_new(str, len)
VALUE rb_str_cat(VALUE, const char *, long)
VALUE rb_str_buf_new(long)
#define rb_str_cat_cstr(buf, str)
VALUE rb_cvar_get(VALUE, ID)
unsigned int OnigCodePoint