~ubuntu-branches/ubuntu/quantal/maas/quantal-proposed

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/escape/escape.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

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']});