Ruby
3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
|
Go to the documentation of this file.
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)]
11 static VALUE rb_cCGI, rb_mUtil, rb_mEscape;
12 static 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}
30 preserve_original_state(
VALUE orig,
VALUE dest)
45 const unsigned char c = *cstr++;
59 preserve_original_state(
str, escaped);
86 for (i = 0; i <
len; i++) {
89 if (c !=
'&')
continue;
91 if (++i >=
len)
break;
92 c = (
unsigned char)cstr[i];
93 #define MATCH(s) (len - i >= (int)rb_strlen_lit(s) && \
94 memcmp(&cstr[i], s, rb_strlen_lit(s)) == 0 && \
95 (i += rb_strlen_lit(s) - 1, 1))
102 else if (
MATCH(
"mp;")) {
132 else if ((cstr[i] ==
'x' || cstr[i] ==
'X') &&
len - ++i >= 2 &&
ISXDIGIT(cstr[i])) {
137 if (overflow || cc >= charlimit || cstr[i] !=
';')
continue;
142 if (charlimit > 256) {
146 c = (
unsigned char)cc;
165 preserve_original_state(
str, dest);
174 url_unreserved_char(
unsigned char c)
177 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
178 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
179 case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
180 case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
181 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
182 case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
183 case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
184 case '-':
case '.':
case '_':
case '~':
195 long i,
len, beg = 0;
203 for (i = 0; i <
len; ++i) {
204 const unsigned char c = (
unsigned char)cstr[i];
205 if (!url_unreserved_char(c)) {
226 preserve_original_state(
str, dest);
237 long i,
len, beg = 0;
246 for (i = 0; i <
len; ++i) {
248 const char c = cstr[i];
251 if (i + 3 >
len)
break;
278 preserve_original_state(
str, dest);
286 if (origenc != encidx) {
310 return optimized_escape_html(
str);
330 return optimized_unescape_html(
str);
350 return optimized_escape(
str);
381 return optimized_unescape(
str, enc);
391 #ifdef HAVE_RB_EXT_RACTOR_SAFE
395 id_accept_charset = rb_intern_const(
"@@accept_charset");
void rb_prepend_module(VALUE klass, VALUE module)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_define_module_under(VALUE outer, const char *name)
const RUBY_EXTERN char ruby_hexdigits[]
rb_encoding * rb_enc_get(VALUE obj)
unsigned int OnigCodePoint
#define ENC_CODERANGE(obj)
#define RSTRING_LEN(string)
RUBY_EXTERN unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow)
#define ENC_CODERANGE_CLEAN_P(cr)
#define rb_str_new(str, len)
#define HTML_ESCAPE(c, str)
int rb_enc_get_index(VALUE obj)
const RUBY_EXTERN signed char ruby_digit36_to_number_table[]
VALUE rb_cObject
Object class.
void rb_ext_ractor_safe(bool flag)
int rb_enc_to_index(rb_encoding *enc)
VALUE rb_call_super(int, const VALUE *)
void rb_extend_object(VALUE obj, VALUE module)
Extend the object with the module.
#define rb_enc_mbcput(c, buf, enc)
VALUE rb_str_cat(VALUE, const char *, long)
unsigned char buf[MIME_BUF_SIZE]
rb_encoding * rb_to_encoding(VALUE enc)
VALUE rb_str_buf_new(long)
#define RSTRING_PTR(string)
char str[HTML_ESCAPE_MAX_LEN+1]
#define ENC_CODERANGE_SET(obj, cr)
#define HTML_ESCAPE_MAX_LEN
#define ENC_CODERANGE_UNKNOWN
#define rb_str_cat_cstr(buf, str)
const typedef OnigEncodingType rb_encoding
int rb_enc_str_coderange(VALUE)
#define rb_enc_str_asciicompat_p(str)
#define char_to_number(c)
VALUE rb_cvar_get(VALUE, ID)
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
VALUE rb_enc_associate_index(VALUE obj, int idx)