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;
15 html_escaped_cat(
VALUE str,
char c)
37 preserve_original_state(
VALUE orig,
VALUE dest)
45 optimized_escape_html(
VALUE str)
54 for (i = 0; i <
len; i++) {
68 html_escaped_cat(dest, cstr[i]);
75 preserve_original_state(str, dest);
84 optimized_unescape_html(
VALUE str)
101 for (i = 0; i <
len; i++) {
104 if (c !=
'&')
continue;
106 if (++i >= len)
break;
107 c = (
unsigned char)cstr[i];
108 #define MATCH(s) (len - i >= (int)rb_strlen_lit(s) && \ 109 memcmp(&cstr[i], s, rb_strlen_lit(s)) == 0 && \ 110 (i += rb_strlen_lit(s) - 1, 1)) 117 else if (
MATCH(
"mp;")) {
144 if (len - ++i >= 2 &&
ISDIGIT(cstr[i])) {
147 else if ((cstr[i] ==
'x' || cstr[i] ==
'X') && len - ++i >= 2 &&
ISXDIGIT(cstr[i])) {
152 if (overflow || cc >= charlimit || cstr[i] !=
';')
continue;
157 if (charlimit > 256) {
161 c = (
unsigned char)cc;
180 preserve_original_state(str, dest);
189 url_unreserved_char(
unsigned char c)
192 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
193 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
194 case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
195 case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
196 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
197 case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
198 case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
199 case '-':
case '.':
case '_':
case '~':
208 optimized_escape(
VALUE str)
210 long i,
len, beg = 0;
218 for (i = 0; i <
len; ++i) {
219 const unsigned char c = (
unsigned char)cstr[i];
220 if (!url_unreserved_char(c)) {
241 preserve_original_state(str, dest);
252 long i,
len, beg = 0;
261 for (i = 0; i <
len; ++i) {
263 const char c = cstr[i];
266 if (i + 3 > len)
break;
293 preserve_original_state(str, dest);
301 if (origenc != encidx) {
325 return optimized_escape_html(str);
345 return optimized_unescape_html(str);
365 return optimized_escape(str);
396 return optimized_unescape(str, enc);
VALUE rb_cvar_get(VALUE, ID)
int rb_enc_get_index(VALUE obj)
unsigned int OnigCodePoint
VALUE rb_str_cat(VALUE, const char *, long)
#define ENC_CODERANGE_SET(obj, cr)
rb_encoding * rb_to_encoding(VALUE enc)
int rb_enc_str_coderange(VALUE)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
RUBY_EXTERN unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow)
void rb_prepend_module(VALUE klass, VALUE module)
int rb_enc_to_index(rb_encoding *enc)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
#define ENC_CODERANGE_CLEAN_P(cr)
#define ENC_CODERANGE_UNKNOWN
VALUE rb_enc_associate_index(VALUE obj, int idx)
#define char_to_number(c)
unsigned char buf[MIME_BUF_SIZE]
#define rb_enc_str_asciicompat_p(str)
VALUE rb_call_super(int, const VALUE *)
register unsigned int len
VALUE rb_define_module_under(VALUE outer, const char *name)
rb_encoding * rb_enc_get(VALUE obj)
void rb_extend_object(VALUE obj, VALUE module)
Extend the object with the module.
#define ENC_CODERANGE(obj)
VALUE rb_str_cat_cstr(VALUE, const char *)
RUBY_EXTERN const signed char ruby_digit36_to_number_table[]
RUBY_EXTERN const char ruby_hexdigits[]
#define rb_intern_const(str)
#define rb_enc_mbcput(c, buf, enc)
VALUE rb_str_buf_new(long)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define RB_OBJ_INFECT_RAW(x, s)