attributewhitelist.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. * @fileoverview Contains the attribute whitelists for use in the Html
  16. * sanitizer.
  17. */
  18. goog.provide('goog.html.sanitizer.AttributeSanitizedWhitelist');
  19. goog.provide('goog.html.sanitizer.AttributeWhitelist');
  20. /**
  21. * A whitelist for attributes that are always safe and allowed by default.
  22. * The sanitizer only applies whitespace trimming to these.
  23. * @const @dict {boolean}
  24. */
  25. goog.html.sanitizer.AttributeWhitelist = {
  26. '* ARIA-CHECKED': true,
  27. '* ARIA-DESCRIBEDBY': true,
  28. '* ARIA-DISABLED': true,
  29. '* ARIA-LABEL': true,
  30. '* ARIA-LABELLEDBY': true,
  31. '* ARIA-READONLY': true,
  32. '* ARIA-REQUIRED': true,
  33. '* ARIA-SELECTED': true,
  34. '* ABBR': true,
  35. '* ACCEPT': true,
  36. '* ACCESSKEY': true,
  37. '* ALIGN': true,
  38. '* ALT': true,
  39. '* AUTOCOMPLETE': true,
  40. '* AXIS': true,
  41. '* BGCOLOR': true,
  42. '* BORDER': true,
  43. '* CELLPADDING': true,
  44. '* CELLSPACING': true,
  45. '* CHAROFF': true,
  46. '* CHAR': true,
  47. '* CHECKED': true,
  48. '* CLEAR': true,
  49. '* COLOR': true,
  50. '* COLSPAN': true,
  51. '* COLS': true,
  52. '* COMPACT': true,
  53. '* COORDS': true,
  54. '* DATETIME': true,
  55. '* DIR': true,
  56. '* DISABLED': true,
  57. '* ENCTYPE': true,
  58. '* FACE': true,
  59. '* FRAME': true,
  60. '* HEIGHT': true,
  61. '* HREFLANG': true,
  62. '* HSPACE': true,
  63. '* ISMAP': true,
  64. '* LABEL': true,
  65. '* LANG': true,
  66. '* MAXLENGTH': true,
  67. '* METHOD': true,
  68. '* MULTIPLE': true,
  69. '* NOHREF': true,
  70. '* NOSHADE': true,
  71. '* NOWRAP': true,
  72. '* READONLY': true,
  73. '* REL': true,
  74. '* REV': true,
  75. '* ROWSPAN': true,
  76. '* ROWS': true,
  77. '* RULES': true,
  78. '* SCOPE': true,
  79. '* SELECTED': true,
  80. '* SHAPE': true,
  81. '* SIZE': true,
  82. '* SPAN': true,
  83. '* START': true,
  84. '* SUMMARY': true,
  85. '* TABINDEX': true,
  86. '* TITLE': true,
  87. '* TYPE': true,
  88. '* VALIGN': true,
  89. '* VALUE': true,
  90. '* VSPACE': true,
  91. '* WIDTH': true
  92. };
  93. /**
  94. * A whitelist for attributes that are not safe to allow unrestricted, but are
  95. * made safe by default policies installed by the sanitizer in
  96. * goog.html.sanitizer.HtmlSanitizer.Builder.prototype.build, and thus allowed
  97. * by default under these policies.
  98. * @const @dict {boolean}
  99. */
  100. goog.html.sanitizer.AttributeSanitizedWhitelist = {
  101. // Attributes which can contain URL fragments
  102. '* USEMAP': true,
  103. // Attributes which can contain URLs
  104. '* ACTION': true,
  105. '* CITE': true,
  106. '* HREF': true,
  107. // Attributes which can cause network requests
  108. '* LONGDESC': true,
  109. '* SRC': true,
  110. 'LINK HREF': true,
  111. // Prevents clobbering
  112. '* FOR': true,
  113. '* HEADERS': true,
  114. '* NAME': true,
  115. // Controls where a window is opened. Prevents tab-nabbing
  116. 'A TARGET': true,
  117. // Attributes which could cause UI redressing.
  118. '* CLASS': true,
  119. '* ID': true,
  120. // CSS style can cause network requests and XSSs
  121. '* STYLE': true
  122. };