~lutostag/ubuntu/utopic/maas/1.5.2

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/yui/3.4.1/escape/escape-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-15 18:14:08 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120315181408-zgl94hzo0x4n99an
Tags: 0.1+bzr295+dfsg-0ubuntu2
* debian/patches:
  - 01-fix-database-settings.patch: Update to set PSERV_URL.
  - 02-pserv-config.patch: Set port to 8001.
* debian/maas.postinst: Run maas-import-isos on install.
* debian/control: Depends on rabbitmq-server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('escape', function(Y) {
8
 
 
9
 
/**
10
 
Provides utility methods for escaping strings.
11
 
 
12
 
@module escape
13
 
@class Escape
14
 
@static
15
 
@since 3.3.0
16
 
**/
17
 
 
18
 
var HTML_CHARS = {
19
 
        '&': '&',
20
 
        '<': '&lt;',
21
 
        '>': '&gt;',
22
 
        '"': '&quot;',
23
 
        "'": '&#x27;',
24
 
        '/': '&#x2F;',
25
 
        '`': '&#x60;'
26
 
    },
27
 
 
28
 
Escape = {
29
 
    // -- Public Static Methods ------------------------------------------------
30
 
 
31
 
    /**
32
 
    Returns a copy of the specified string with special HTML characters
33
 
    escaped. The following characters will be converted to their
34
 
    corresponding character entities:
35
 
 
36
 
        & < > " ' / `
37
 
 
38
 
    This implementation is based on the [OWASP HTML escaping
39
 
    recommendations][1]. In addition to the characters in the OWASP
40
 
    recommendations, we also escape the <code>&#x60;</code> character, since IE
41
 
    interprets it as an attribute delimiter.
42
 
 
43
 
    If _string_ is not already a string, it will be coerced to a string.
44
 
 
45
 
    [1]: http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
46
 
 
47
 
    @method html
48
 
    @param {String} string String to escape.
49
 
    @return {String} Escaped string.
50
 
    @static
51
 
    **/
52
 
    html: function (string) {
53
 
        return (string + '').replace(/[&<>"'\/`]/g, Escape._htmlReplacer);
54
 
    },
55
 
 
56
 
    /**
57
 
    Returns a copy of the specified string with special regular expression
58
 
    characters escaped, allowing the string to be used safely inside a regex.
59
 
    The following characters, and all whitespace characters, are escaped:
60
 
 
61
 
        - # $ ^ * ( ) + [ ] { } | \ , . ?
62
 
 
63
 
    If _string_ is not already a string, it will be coerced to a string.
64
 
 
65
 
    @method regex
66
 
    @param {String} string String to escape.
67
 
    @return {String} Escaped string.
68
 
    @static
69
 
    **/
70
 
    regex: function (string) {
71
 
        return (string + '').replace(/[\-#$\^*()+\[\]{}|\\,.?\s]/g, '\\$&');
72
 
    },
73
 
 
74
 
    // -- Protected Static Methods ---------------------------------------------
75
 
 
76
 
    /**
77
 
     * Regex replacer for HTML escaping.
78
 
     *
79
 
     * @method _htmlReplacer
80
 
     * @param {String} match Matched character (must exist in HTML_CHARS).
81
 
     * @returns {String} HTML entity.
82
 
     * @static
83
 
     * @protected
84
 
     */
85
 
    _htmlReplacer: function (match) {
86
 
        return HTML_CHARS[match];
87
 
    }
88
 
};
89
 
 
90
 
Escape.regexp = Escape.regex;
91
 
 
92
 
Y.Escape = Escape;
93
 
 
94
 
 
95
 
}, '3.4.1' ,{requires:['yui-base']});