Module: CGI::Escape

Defined in:
escape/escape.c

Instance Method Summary collapse

Instance Method Details

#escape(string) ⇒ String

Returns URL-escaped string.

Returns:

  • (String)


344
345
346
347
348
349
350
351
352
353
354
355
# File 'escape/escape.c', line 344

static VALUE
cgiesc_escape(VALUE self, VALUE str)
{
    StringValue(str);

    if (rb_enc_str_asciicompat_p(str)) {
	return optimized_escape(str);
    }
    else {
	return rb_call_super(1, &str);
    }
}

#escapeHTML(string) ⇒ String

Returns HTML-escaped string.

Returns:

  • (String)


304
305
306
307
308
309
310
311
312
313
314
315
# File 'escape/escape.c', line 304

static VALUE
cgiesc_escape_html(VALUE self, VALUE str)
{
    StringValue(str);

    if (rb_enc_str_asciicompat_p(str)) {
	return optimized_escape_html(str);
    }
    else {
	return rb_call_super(1, &str);
    }
}

#unescape(string, encoding = @@accept_charset) ⇒ String

Returns URL-unescaped string.

Returns:

  • (String)


372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'escape/escape.c', line 372

static VALUE
cgiesc_unescape(int argc, VALUE *argv, VALUE self)
{
    VALUE str = (rb_check_arity(argc, 1, 2), argv[0]);

    StringValue(str);

    if (rb_enc_str_asciicompat_p(str)) {
	VALUE enc = accept_charset(argc-1, argv+1, self);
	return optimized_unescape(str, enc);
    }
    else {
	return rb_call_super(argc, argv);
    }
}

#unescapeHTML(string) ⇒ String

Returns HTML-unescaped string.

Returns:

  • (String)


324
325
326
327
328
329
330
331
332
333
334
335
# File 'escape/escape.c', line 324

static VALUE
cgiesc_unescape_html(VALUE self, VALUE str)
{
    StringValue(str);

    if (rb_enc_str_asciicompat_p(str)) {
	return optimized_unescape_html(str);
    }
    else {
	return rb_call_super(1, &str);
    }
}