| 1 |
// Copyright 2016 The Closure Library Authors. All Rights Reserved. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS-IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* @fileoverview Contains the attribute whitelists for use in the Html |
| 18 |
* sanitizer. |
| 19 |
*/ |
| 20 |
|
| 21 |
goog.provide('goog.html.sanitizer.AttributeSanitizedWhitelist'); |
| 22 |
goog.provide('goog.html.sanitizer.AttributeWhitelist'); |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* A whitelist for attributes that are always safe and allowed by default. |
| 27 |
* The sanitizer only applies whitespace trimming to these. |
| 28 |
* @const @dict {boolean} |
| 29 |
*/ |
| 30 |
goog.html.sanitizer.AttributeWhitelist = { |
| 31 |
'* ARIA-CHECKED': true, |
| 32 |
'* ARIA-COLCOUNT': true, |
| 33 |
'* ARIA-COLINDEX': true, |
| 34 |
'* ARIA-DESCRIBEDBY': true, |
| 35 |
'* ARIA-DISABLED': true, |
| 36 |
'* ARIA-LABEL': true, |
| 37 |
'* ARIA-LABELLEDBY': true, |
| 38 |
'* ARIA-READONLY': true, |
| 39 |
'* ARIA-REQUIRED': true, |
| 40 |
'* ARIA-ROWCOUNT': true, |
| 41 |
'* ARIA-ROWINDEX': true, |
| 42 |
'* ARIA-SELECTED': true, |
| 43 |
'* ABBR': true, |
| 44 |
'* ACCEPT': true, |
| 45 |
'* ACCESSKEY': true, |
| 46 |
'* ALIGN': true, |
| 47 |
'* ALT': true, |
| 48 |
'* AUTOCOMPLETE': true, |
| 49 |
'* AXIS': true, |
| 50 |
'* BGCOLOR': true, |
| 51 |
'* BORDER': true, |
| 52 |
'* CELLPADDING': true, |
| 53 |
'* CELLSPACING': true, |
| 54 |
'* CHAROFF': true, |
| 55 |
'* CHAR': true, |
| 56 |
'* CHECKED': true, |
| 57 |
'* CLEAR': true, |
| 58 |
'* COLOR': true, |
| 59 |
'* COLSPAN': true, |
| 60 |
'* COLS': true, |
| 61 |
'* COMPACT': true, |
| 62 |
'* COORDS': true, |
| 63 |
'* DATETIME': true, |
| 64 |
'* DIR': true, |
| 65 |
'* DISABLED': true, |
| 66 |
'* ENCTYPE': true, |
| 67 |
'* FACE': true, |
| 68 |
'* FRAME': true, |
| 69 |
'* HEIGHT': true, |
| 70 |
'* HREFLANG': true, |
| 71 |
'* HSPACE': true, |
| 72 |
'* ISMAP': true, |
| 73 |
'* LABEL': true, |
| 74 |
'* LANG': true, |
| 75 |
'* MAXLENGTH': true, |
| 76 |
'* METHOD': true, |
| 77 |
'* MULTIPLE': true, |
| 78 |
'* NOHREF': true, |
| 79 |
'* NOSHADE': true, |
| 80 |
'* NOWRAP': true, |
| 81 |
'* READONLY': true, |
| 82 |
'* REL': true, |
| 83 |
'* REV': true, |
| 84 |
'* ROLE': true, |
| 85 |
'* ROWSPAN': true, |
| 86 |
'* ROWS': true, |
| 87 |
'* RULES': true, |
| 88 |
'* SCOPE': true, |
| 89 |
'* SELECTED': true, |
| 90 |
'* SHAPE': true, |
| 91 |
'* SIZE': true, |
| 92 |
'* SPAN': true, |
| 93 |
'* START': true, |
| 94 |
'* SUMMARY': true, |
| 95 |
'* TABINDEX': true, |
| 96 |
'* TITLE': true, |
| 97 |
'* TYPE': true, |
| 98 |
'* VALIGN': true, |
| 99 |
'* VALUE': true, |
| 100 |
'* VSPACE': true, |
| 101 |
'* WIDTH': true |
| 102 |
}; |
| 103 |
|
| 104 |
/** |
| 105 |
* A whitelist for attributes that are not safe to allow unrestricted, but are |
| 106 |
* made safe by default policies installed by the sanitizer in |
| 107 |
* goog.html.sanitizer.HtmlSanitizer.Builder.prototype.build, and thus allowed |
| 108 |
* by default under these policies. |
| 109 |
* @const @dict {boolean} |
| 110 |
*/ |
| 111 |
goog.html.sanitizer.AttributeSanitizedWhitelist = { |
| 112 |
|
| 113 |
// Attributes which can contain URL fragments |
| 114 |
'* USEMAP': true, |
| 115 |
// Attributes which can contain URLs |
| 116 |
'* ACTION': true, |
| 117 |
'* CITE': true, |
| 118 |
'* HREF': true, |
| 119 |
// Attributes which can cause network requests |
| 120 |
'* LONGDESC': true, |
| 121 |
'* SRC': true, |
| 122 |
'LINK HREF': true, |
| 123 |
// Prevents clobbering |
| 124 |
'* FOR': true, |
| 125 |
'* HEADERS': true, |
| 126 |
'* NAME': true, |
| 127 |
// Controls where a window is opened. Prevents tab-nabbing |
| 128 |
'A TARGET': true, |
| 129 |
|
| 130 |
// Attributes which could cause UI redressing. |
| 131 |
'* CLASS': true, |
| 132 |
'* ID': true, |
| 133 |
|
| 134 |
// CSS style can cause network requests and XSSs |
| 135 |
'* STYLE': true |
| 136 |
}; |