@ui5/webcomponents-base 2.0.0-rc.3 → 2.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/Boot.js +1 -1
- package/dist/Boot.js.map +1 -1
- package/dist/Keys.d.ts +2 -1
- package/dist/Keys.js +2 -1
- package/dist/Keys.js.map +1 -1
- package/dist/UI5Element.d.ts +9 -1
- package/dist/UI5Element.js +73 -12
- package/dist/UI5Element.js.map +1 -1
- package/dist/UI5ElementMetadata.d.ts +5 -0
- package/dist/UI5ElementMetadata.js +6 -0
- package/dist/UI5ElementMetadata.js.map +1 -1
- package/dist/config/AnimationMode.js +2 -1
- package/dist/config/AnimationMode.js.map +1 -1
- package/dist/custom-elements-internal.json +6 -15
- package/dist/custom-elements.json +6 -15
- package/dist/decorators/customElement.d.ts +1 -0
- package/dist/decorators/customElement.js +5 -2
- package/dist/decorators/customElement.js.map +1 -1
- package/dist/features/InputElementsFormSupport.d.ts +18 -0
- package/dist/features/InputElementsFormSupport.js +40 -0
- package/dist/features/InputElementsFormSupport.js.map +1 -0
- package/dist/generated/VersionInfo.js +3 -3
- package/dist/generated/VersionInfo.js.map +1 -1
- package/dist/prod/AssetRegistry.js +2 -0
- package/dist/prod/AssetRegistry.js.map +7 -0
- package/dist/prod/Boot.js +2 -0
- package/dist/prod/Boot.js.map +7 -0
- package/dist/prod/CustomElementsRegistry.js +10 -0
- package/dist/prod/CustomElementsRegistry.js.map +7 -0
- package/dist/prod/CustomElementsScope.js +2 -0
- package/dist/prod/CustomElementsScope.js.map +7 -0
- package/dist/prod/CustomElementsScopeUtils.js +2 -0
- package/dist/prod/CustomElementsScopeUtils.js.map +7 -0
- package/dist/prod/DOMObserver.js +2 -0
- package/dist/prod/DOMObserver.js.map +7 -0
- package/dist/prod/Device.js +2 -0
- package/dist/prod/Device.js.map +7 -0
- package/dist/prod/EventProvider.js +2 -0
- package/dist/prod/EventProvider.js.map +7 -0
- package/dist/prod/FeaturesRegistry.js +2 -0
- package/dist/prod/FeaturesRegistry.js.map +7 -0
- package/dist/prod/FontFace.js +2 -0
- package/dist/prod/FontFace.js.map +7 -0
- package/dist/prod/IgnoreCustomElements.js +2 -0
- package/dist/prod/IgnoreCustomElements.js.map +7 -0
- package/dist/prod/InitialConfiguration.js +2 -0
- package/dist/prod/InitialConfiguration.js.map +7 -0
- package/dist/prod/Keys.js +2 -0
- package/dist/prod/Keys.js.map +7 -0
- package/dist/prod/ManagedStyles.js +2 -0
- package/dist/prod/ManagedStyles.js.map +7 -0
- package/dist/prod/MarkedEvents.js +2 -0
- package/dist/prod/MarkedEvents.js.map +7 -0
- package/dist/prod/MediaRange.js +2 -0
- package/dist/prod/MediaRange.js.map +7 -0
- package/dist/prod/PropertiesFileFormat.js +3 -0
- package/dist/prod/PropertiesFileFormat.js.map +7 -0
- package/dist/prod/Render.js +2 -0
- package/dist/prod/Render.js.map +7 -0
- package/dist/prod/RenderQueue.js +2 -0
- package/dist/prod/RenderQueue.js.map +7 -0
- package/dist/prod/Runtimes.js +2 -0
- package/dist/prod/Runtimes.js.map +7 -0
- package/dist/prod/SystemCSSVars.js +2 -0
- package/dist/prod/SystemCSSVars.js.map +7 -0
- package/dist/prod/Theming.js +2 -0
- package/dist/prod/Theming.js.map +7 -0
- package/dist/prod/UI5Element.js +2 -0
- package/dist/prod/UI5Element.js.map +7 -0
- package/dist/prod/UI5ElementMetadata.js +2 -0
- package/dist/prod/UI5ElementMetadata.js.map +7 -0
- package/dist/prod/animations/AnimationQueue.js +2 -0
- package/dist/prod/animations/AnimationQueue.js.map +7 -0
- package/dist/prod/animations/animate.js +2 -0
- package/dist/prod/animations/animate.js.map +7 -0
- package/dist/prod/animations/scroll.js +2 -0
- package/dist/prod/animations/scroll.js.map +7 -0
- package/dist/prod/animations/slideDown.js +2 -0
- package/dist/prod/animations/slideDown.js.map +7 -0
- package/dist/prod/animations/slideUp.js +2 -0
- package/dist/prod/animations/slideUp.js.map +7 -0
- package/dist/prod/asset-registries/Icons.js +2 -0
- package/dist/prod/asset-registries/Icons.js.map +7 -0
- package/dist/prod/asset-registries/Illustrations.js +2 -0
- package/dist/prod/asset-registries/Illustrations.js.map +7 -0
- package/dist/prod/asset-registries/LocaleData.js +2 -0
- package/dist/prod/asset-registries/LocaleData.js.map +7 -0
- package/dist/prod/asset-registries/Themes.js +2 -0
- package/dist/prod/asset-registries/Themes.js.map +7 -0
- package/dist/prod/asset-registries/i18n.js +2 -0
- package/dist/prod/asset-registries/i18n.js.map +7 -0
- package/dist/prod/asset-registries/util/IconCollectionsAlias.js +2 -0
- package/dist/prod/asset-registries/util/IconCollectionsAlias.js.map +7 -0
- package/dist/prod/asset-registries/util/IconCollectionsByTheme.js +2 -0
- package/dist/prod/asset-registries/util/IconCollectionsByTheme.js.map +7 -0
- package/dist/prod/asset-registries/util/getIconCollectionByTheme.js +2 -0
- package/dist/prod/asset-registries/util/getIconCollectionByTheme.js.map +7 -0
- package/dist/prod/config/AnimationMode.js +2 -0
- package/dist/prod/config/AnimationMode.js.map +7 -0
- package/dist/prod/config/CalendarType.js +2 -0
- package/dist/prod/config/CalendarType.js.map +7 -0
- package/dist/prod/config/FormatSettings.js +2 -0
- package/dist/prod/config/FormatSettings.js.map +7 -0
- package/dist/prod/config/Icons.js +2 -0
- package/dist/prod/config/Icons.js.map +7 -0
- package/dist/prod/config/Language.js +2 -0
- package/dist/prod/config/Language.js.map +7 -0
- package/dist/prod/config/NoConflict.js +2 -0
- package/dist/prod/config/NoConflict.js.map +7 -0
- package/dist/prod/config/Theme.js +2 -0
- package/dist/prod/config/Theme.js.map +7 -0
- package/dist/prod/config/ThemeRoot.js +2 -0
- package/dist/prod/config/ThemeRoot.js.map +7 -0
- package/dist/prod/config/Timezone.js +2 -0
- package/dist/prod/config/Timezone.js.map +7 -0
- package/dist/prod/connectToComponent.js +2 -0
- package/dist/prod/connectToComponent.js.map +7 -0
- package/dist/prod/decorators/customElement.js +2 -0
- package/dist/prod/decorators/customElement.js.map +7 -0
- package/dist/prod/decorators/event.js +2 -0
- package/dist/prod/decorators/event.js.map +7 -0
- package/dist/prod/decorators/property.js +2 -0
- package/dist/prod/decorators/property.js.map +7 -0
- package/dist/prod/decorators/slot.js +2 -0
- package/dist/prod/decorators/slot.js.map +7 -0
- package/dist/prod/decorators.js +2 -0
- package/dist/prod/decorators.js.map +7 -0
- package/dist/prod/delegate/ItemNavigation.js +2 -0
- package/dist/prod/delegate/ItemNavigation.js.map +7 -0
- package/dist/prod/delegate/ResizeHandler.js +2 -0
- package/dist/prod/delegate/ResizeHandler.js.map +7 -0
- package/dist/prod/delegate/ScrollEnablement.js +2 -0
- package/dist/prod/delegate/ScrollEnablement.js.map +7 -0
- package/dist/prod/features/F6Navigation.js +2 -0
- package/dist/prod/features/F6Navigation.js.map +7 -0
- package/dist/prod/features/InputElementsFormSupport.js +2 -0
- package/dist/prod/features/InputElementsFormSupport.js.map +7 -0
- package/dist/prod/features/LegacyDateFormats.js +2 -0
- package/dist/prod/features/LegacyDateFormats.js.map +7 -0
- package/dist/prod/features/OpenUI5Element.js +2 -0
- package/dist/prod/features/OpenUI5Element.js.map +7 -0
- package/dist/prod/features/OpenUI5Enablement.js +21 -0
- package/dist/prod/features/OpenUI5Enablement.js.map +7 -0
- package/dist/prod/features/OpenUI5Support.js +2 -0
- package/dist/prod/features/OpenUI5Support.js.map +7 -0
- package/dist/prod/features/patchPatcher.js +2 -0
- package/dist/prod/features/patchPatcher.js.map +7 -0
- package/dist/prod/features/patchPopup.js +2 -0
- package/dist/prod/features/patchPopup.js.map +7 -0
- package/dist/prod/generated/AssetParameters.js +2 -0
- package/dist/prod/generated/AssetParameters.js.map +7 -0
- package/dist/prod/generated/VersionInfo.js +2 -0
- package/dist/prod/generated/VersionInfo.js.map +7 -0
- package/dist/prod/generated/css/BusyIndicator.css.js +2 -0
- package/dist/prod/generated/css/BusyIndicator.css.js.map +7 -0
- package/dist/prod/generated/css/FontFace.css.js +2 -0
- package/dist/prod/generated/css/FontFace.css.js.map +7 -0
- package/dist/prod/generated/css/OverrideFontFace.css.js +2 -0
- package/dist/prod/generated/css/OverrideFontFace.css.js.map +7 -0
- package/dist/prod/generated/css/SystemCSSVars.css.js +2 -0
- package/dist/prod/generated/css/SystemCSSVars.css.js.map +7 -0
- package/dist/prod/generated/templates/elements/WithComplexTemplateTemplate.lit.js +2 -0
- package/dist/prod/generated/templates/elements/WithComplexTemplateTemplate.lit.js.map +7 -0
- package/dist/prod/getSharedResource.js +2 -0
- package/dist/prod/getSharedResource.js.map +7 -0
- package/dist/prod/global.d.js +2 -0
- package/dist/prod/global.d.js.map +7 -0
- package/dist/prod/i18nBundle.js +2 -0
- package/dist/prod/i18nBundle.js.map +7 -0
- package/dist/prod/locale/Locale.js +2 -0
- package/dist/prod/locale/Locale.js.map +7 -0
- package/dist/prod/locale/RTLAwareRegistry.js +2 -0
- package/dist/prod/locale/RTLAwareRegistry.js.map +7 -0
- package/dist/prod/locale/applyDirection.js +2 -0
- package/dist/prod/locale/applyDirection.js.map +7 -0
- package/dist/prod/locale/directionChange.js +2 -0
- package/dist/prod/locale/directionChange.js.map +7 -0
- package/dist/prod/locale/getEffectiveDir.js +2 -0
- package/dist/prod/locale/getEffectiveDir.js.map +7 -0
- package/dist/prod/locale/getLocale.js +2 -0
- package/dist/prod/locale/getLocale.js.map +7 -0
- package/dist/prod/locale/languageChange.js +2 -0
- package/dist/prod/locale/languageChange.js.map +7 -0
- package/dist/prod/locale/nextFallbackLocale.js +2 -0
- package/dist/prod/locale/nextFallbackLocale.js.map +7 -0
- package/dist/prod/locale/normalizeLocale.js +2 -0
- package/dist/prod/locale/normalizeLocale.js.map +7 -0
- package/dist/prod/renderer/LitRenderer.js +2 -0
- package/dist/prod/renderer/LitRenderer.js.map +7 -0
- package/dist/prod/renderer/directives/style-map.js +6 -0
- package/dist/prod/renderer/directives/style-map.js.map +7 -0
- package/dist/prod/renderer/executeTemplate.js +2 -0
- package/dist/prod/renderer/executeTemplate.js.map +7 -0
- package/dist/prod/sap/base/Log.js +750 -0
- package/dist/prod/sap/base/assert.js +34 -0
- package/dist/prod/sap/base/config/MemoryConfigurationProvider.js +20 -0
- package/dist/prod/sap/base/security/URLListValidator.js +406 -0
- package/dist/prod/sap/base/security/encodeCSS.js +40 -0
- package/dist/prod/sap/base/security/encodeXML.js +53 -0
- package/dist/prod/sap/base/security/sanitizeHTML.js +38 -0
- package/dist/prod/sap/base/strings/toHex.js +33 -0
- package/dist/prod/sap/base/util/now.js +28 -0
- package/dist/prod/sap/base/util/uid.js +27 -0
- package/dist/prod/sap/ui/thirdparty/caja-html-sanitizer.js +3600 -0
- package/dist/prod/ssr-dom-shim.js +2 -0
- package/dist/prod/ssr-dom-shim.js.map +7 -0
- package/dist/prod/ssr-dom.js +2 -0
- package/dist/prod/ssr-dom.js.map +7 -0
- package/dist/prod/theming/CustomStyle.js +2 -0
- package/dist/prod/theming/CustomStyle.js.map +7 -0
- package/dist/prod/theming/ThemeLoaded.js +2 -0
- package/dist/prod/theming/ThemeLoaded.js.map +7 -0
- package/dist/prod/theming/ThemeRegistered.js +2 -0
- package/dist/prod/theming/ThemeRegistered.js.map +7 -0
- package/dist/prod/theming/applyTheme.js +2 -0
- package/dist/prod/theming/applyTheme.js.map +7 -0
- package/dist/prod/theming/getConstructableStyle.js +2 -0
- package/dist/prod/theming/getConstructableStyle.js.map +7 -0
- package/dist/prod/theming/getEffectiveStyle.js +2 -0
- package/dist/prod/theming/getEffectiveStyle.js.map +7 -0
- package/dist/prod/theming/getStylesString.js +2 -0
- package/dist/prod/theming/getStylesString.js.map +7 -0
- package/dist/prod/theming/getThemeDesignerTheme.js +2 -0
- package/dist/prod/theming/getThemeDesignerTheme.js.map +7 -0
- package/dist/prod/thirdparty/_merge.js +2 -0
- package/dist/prod/thirdparty/_merge.js.map +7 -0
- package/dist/prod/thirdparty/isPlainObject.js +2 -0
- package/dist/prod/thirdparty/isPlainObject.js.map +7 -0
- package/dist/prod/thirdparty/merge.js +2 -0
- package/dist/prod/thirdparty/merge.js.map +7 -0
- package/dist/prod/types/AnimationMode.js +2 -0
- package/dist/prod/types/AnimationMode.js.map +7 -0
- package/dist/prod/types/AriaHasPopup.js +2 -0
- package/dist/prod/types/AriaHasPopup.js.map +7 -0
- package/dist/prod/types/AriaLandmarkRole.js +2 -0
- package/dist/prod/types/AriaLandmarkRole.js.map +7 -0
- package/dist/prod/types/AriaRole.js +2 -0
- package/dist/prod/types/AriaRole.js.map +7 -0
- package/dist/prod/types/CSSColor.js +2 -0
- package/dist/prod/types/CSSColor.js.map +7 -0
- package/dist/prod/types/CSSSize.js +2 -0
- package/dist/prod/types/CSSSize.js.map +7 -0
- package/dist/prod/types/CalendarType.js +2 -0
- package/dist/prod/types/CalendarType.js.map +7 -0
- package/dist/prod/types/DOMReference.js +2 -0
- package/dist/prod/types/DOMReference.js.map +7 -0
- package/dist/prod/types/DataType.js +2 -0
- package/dist/prod/types/DataType.js.map +7 -0
- package/dist/prod/types/Float.js +2 -0
- package/dist/prod/types/Float.js.map +7 -0
- package/dist/prod/types/Integer.js +2 -0
- package/dist/prod/types/Integer.js.map +7 -0
- package/dist/prod/types/InvisibleMessageMode.js +2 -0
- package/dist/prod/types/InvisibleMessageMode.js.map +7 -0
- package/dist/prod/types/ItemNavigationBehavior.js +2 -0
- package/dist/prod/types/ItemNavigationBehavior.js.map +7 -0
- package/dist/prod/types/MovePlacement.js +2 -0
- package/dist/prod/types/MovePlacement.js.map +7 -0
- package/dist/prod/types/NavigationMode.js +2 -0
- package/dist/prod/types/NavigationMode.js.map +7 -0
- package/dist/prod/types/Orientation.js +2 -0
- package/dist/prod/types/Orientation.js.map +7 -0
- package/dist/prod/types/ValueState.js +2 -0
- package/dist/prod/types/ValueState.js.map +7 -0
- package/dist/prod/types.js +2 -0
- package/dist/prod/types.js.map +7 -0
- package/dist/prod/updateShadowRoot.js +2 -0
- package/dist/prod/updateShadowRoot.js.map +7 -0
- package/dist/prod/util/AriaLabelHelper.js +2 -0
- package/dist/prod/util/AriaLabelHelper.js.map +7 -0
- package/dist/prod/util/Caret.js +2 -0
- package/dist/prod/util/Caret.js.map +7 -0
- package/dist/prod/util/ColorConversion.js +2 -0
- package/dist/prod/util/ColorConversion.js.map +7 -0
- package/dist/prod/util/FetchHelper.js +2 -0
- package/dist/prod/util/FetchHelper.js.map +7 -0
- package/dist/prod/util/FocusableElements.js +2 -0
- package/dist/prod/util/FocusableElements.js.map +7 -0
- package/dist/prod/util/HTMLSanitizer.js +2 -0
- package/dist/prod/util/HTMLSanitizer.js.map +7 -0
- package/dist/prod/util/InvisibleMessage.js +2 -0
- package/dist/prod/util/InvisibleMessage.js.map +7 -0
- package/dist/prod/util/PopupUtils.js +2 -0
- package/dist/prod/util/PopupUtils.js.map +7 -0
- package/dist/prod/util/SlotsHelper.js +2 -0
- package/dist/prod/util/SlotsHelper.js.map +7 -0
- package/dist/prod/util/StringHelper.js +2 -0
- package/dist/prod/util/StringHelper.js.map +7 -0
- package/dist/prod/util/TabbableElements.js +2 -0
- package/dist/prod/util/TabbableElements.js.map +7 -0
- package/dist/prod/util/arraysAreEqual.js +2 -0
- package/dist/prod/util/arraysAreEqual.js.map +7 -0
- package/dist/prod/util/clamp.js +2 -0
- package/dist/prod/util/clamp.js.map +7 -0
- package/dist/prod/util/createLinkInHead.js +2 -0
- package/dist/prod/util/createLinkInHead.js.map +7 -0
- package/dist/prod/util/debounce.js +2 -0
- package/dist/prod/util/debounce.js.map +7 -0
- package/dist/prod/util/detectNavigatorLanguage.js +2 -0
- package/dist/prod/util/detectNavigatorLanguage.js.map +7 -0
- package/dist/prod/util/dragAndDrop/DragRegistry.js +2 -0
- package/dist/prod/util/dragAndDrop/DragRegistry.js.map +7 -0
- package/dist/prod/util/dragAndDrop/findClosestPosition.js +2 -0
- package/dist/prod/util/dragAndDrop/findClosestPosition.js.map +7 -0
- package/dist/prod/util/dragAndDrop/longDragOverHandler.js +2 -0
- package/dist/prod/util/dragAndDrop/longDragOverHandler.js.map +7 -0
- package/dist/prod/util/escapeRegex.js +2 -0
- package/dist/prod/util/escapeRegex.js.map +7 -0
- package/dist/prod/util/formatMessage.js +2 -0
- package/dist/prod/util/formatMessage.js.map +7 -0
- package/dist/prod/util/generateHighlightedMarkup.js +2 -0
- package/dist/prod/util/generateHighlightedMarkup.js.map +7 -0
- package/dist/prod/util/getActiveElement.js +2 -0
- package/dist/prod/util/getActiveElement.js.map +7 -0
- package/dist/prod/util/getClassCopy.js +2 -0
- package/dist/prod/util/getClassCopy.js.map +7 -0
- package/dist/prod/util/getDesigntimePropertyAsArray.js +2 -0
- package/dist/prod/util/getDesigntimePropertyAsArray.js.map +7 -0
- package/dist/prod/util/getEffectiveContentDensity.js +2 -0
- package/dist/prod/util/getEffectiveContentDensity.js.map +7 -0
- package/dist/prod/util/getEffectiveScrollbarStyle.js +2 -0
- package/dist/prod/util/getEffectiveScrollbarStyle.js.map +7 -0
- package/dist/prod/util/getFastNavigationGroups.js +2 -0
- package/dist/prod/util/getFastNavigationGroups.js.map +7 -0
- package/dist/prod/util/getFileExtension.js +2 -0
- package/dist/prod/util/getFileExtension.js.map +7 -0
- package/dist/prod/util/getNormalizedTarget.js +2 -0
- package/dist/prod/util/getNormalizedTarget.js.map +7 -0
- package/dist/prod/util/getParentElement.js +2 -0
- package/dist/prod/util/getParentElement.js.map +7 -0
- package/dist/prod/util/getSingletonElementInstance.js +2 -0
- package/dist/prod/util/getSingletonElementInstance.js.map +7 -0
- package/dist/prod/util/isElementClickable.js +2 -0
- package/dist/prod/util/isElementClickable.js.map +7 -0
- package/dist/prod/util/isElementContainingBlock.js +2 -0
- package/dist/prod/util/isElementContainingBlock.js.map +7 -0
- package/dist/prod/util/isElementHidden.js +2 -0
- package/dist/prod/util/isElementHidden.js.map +7 -0
- package/dist/prod/util/isElementInView.js +2 -0
- package/dist/prod/util/isElementInView.js.map +7 -0
- package/dist/prod/util/isElementTabbable.js +2 -0
- package/dist/prod/util/isElementTabbable.js.map +7 -0
- package/dist/prod/util/isValidPropertyName.js +2 -0
- package/dist/prod/util/isValidPropertyName.js.map +7 -0
- package/dist/prod/util/whenDOMReady.js +2 -0
- package/dist/prod/util/whenDOMReady.js.map +7 -0
- package/dist/prod/util/willShowContent.js +2 -0
- package/dist/prod/util/willShowContent.js.map +7 -0
- package/dist/prod/validateThemeRoot.js +2 -0
- package/dist/prod/validateThemeRoot.js.map +7 -0
- package/dist/renderer/executeTemplate.d.ts +8 -0
- package/dist/renderer/executeTemplate.js +1 -0
- package/dist/renderer/executeTemplate.js.map +1 -1
- package/dist/util/InvisibleMessage.js +2 -2
- package/dist/util/InvisibleMessage.js.map +1 -1
- package/dist/util/getClassCopy.d.ts +9 -1
- package/package-scripts.cjs +5 -0
- package/package.json +11 -5
- package/dist/StaticArea.d.ts +0 -3
- package/dist/StaticArea.js +0 -7
- package/dist/StaticArea.js.map +0 -1
|
@@ -0,0 +1,3600 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
/* Copyright Google Inc.
|
|
3
|
+
* Licensed under the Apache Licence Version 2.0
|
|
4
|
+
* Autogenerated at Tue May 22 10:18:21 PDT 2012
|
|
5
|
+
* \@overrides window
|
|
6
|
+
* \@provides cssSchema, CSS_PROP_BIT_QUANTITY, CSS_PROP_BIT_HASH_VALUE, CSS_PROP_BIT_NEGATIVE_QUANTITY, CSS_PROP_BIT_QSTRING_CONTENT, CSS_PROP_BIT_QSTRING_URL, CSS_PROP_BIT_HISTORY_INSENSITIVE, CSS_PROP_BIT_Z_INDEX, CSS_PROP_BIT_ALLOWED_IN_LINK */
|
|
7
|
+
/**
|
|
8
|
+
* @const
|
|
9
|
+
* @type {number}
|
|
10
|
+
*/
|
|
11
|
+
var CSS_PROP_BIT_QUANTITY = 1;
|
|
12
|
+
/**
|
|
13
|
+
* @const
|
|
14
|
+
* @type {number}
|
|
15
|
+
*/
|
|
16
|
+
var CSS_PROP_BIT_HASH_VALUE = 2;
|
|
17
|
+
/**
|
|
18
|
+
* @const
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
var CSS_PROP_BIT_NEGATIVE_QUANTITY = 4;
|
|
22
|
+
/**
|
|
23
|
+
* @const
|
|
24
|
+
* @type {number}
|
|
25
|
+
*/
|
|
26
|
+
var CSS_PROP_BIT_QSTRING_CONTENT = 8;
|
|
27
|
+
/**
|
|
28
|
+
* @const
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
var CSS_PROP_BIT_QSTRING_URL = 16;
|
|
32
|
+
/**
|
|
33
|
+
* @const
|
|
34
|
+
* @type {number}
|
|
35
|
+
*/
|
|
36
|
+
var CSS_PROP_BIT_HISTORY_INSENSITIVE = 32;
|
|
37
|
+
/**
|
|
38
|
+
* @const
|
|
39
|
+
* @type {number}
|
|
40
|
+
*/
|
|
41
|
+
var CSS_PROP_BIT_Z_INDEX = 64;
|
|
42
|
+
/**
|
|
43
|
+
* @const
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
var CSS_PROP_BIT_ALLOWED_IN_LINK = 128;
|
|
47
|
+
var cssSchema = (function () {
|
|
48
|
+
var s = [
|
|
49
|
+
'rgb(?:\\(\\s*(?:\\d+|0|\\d+(?:\\.\\d+)?%)\\s*,\\s*(?:\\d+|0|\\d+(?:\\.\\d+)?%)\\s*,\\s*(?:\\d+|0|\\d+(?:\\.\\d+)?%)|a\\(\\s*(?:\\d+|0|\\d+(?:\\.\\d+)?%)\\s*,\\s*(?:\\d+|0|\\d+(?:\\.\\d+)?%)\\s*,\\s*(?:\\d+|0|\\d+(?:\\.\\d+)?%)\\s*,\\s*(?:\\d+|0(?:\\.\\d+)?|\\.\\d+|1(?:\\.0+)?|0|\\d+(?:\\.\\d+)?%)) *\\)'
|
|
50
|
+
], c = [ /^ *$/i, RegExp('^ *(?:\\s*' + s[ 0 ] + '|(?:\\s*' + s[ 0 ] +
|
|
51
|
+
')?)+ *$', 'i'), RegExp('^ *\\s*' + s[ 0 ] + ' *$', 'i'),
|
|
52
|
+
RegExp('^ *\\s*' + s[ 0 ] + '\\s*' + s[ 0 ] + ' *$', 'i') ], L = [ [
|
|
53
|
+
'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige',
|
|
54
|
+
'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown',
|
|
55
|
+
'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral',
|
|
56
|
+
'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue',
|
|
57
|
+
'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkkhaki',
|
|
58
|
+
'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred',
|
|
59
|
+
'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray',
|
|
60
|
+
'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray',
|
|
61
|
+
'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia',
|
|
62
|
+
'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green',
|
|
63
|
+
'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory',
|
|
64
|
+
'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon',
|
|
65
|
+
'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow',
|
|
66
|
+
'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen',
|
|
67
|
+
'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow',
|
|
68
|
+
'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine',
|
|
69
|
+
'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen',
|
|
70
|
+
'mediumslateblue', 'mediumspringgreen', 'mediumturquoise',
|
|
71
|
+
'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose',
|
|
72
|
+
'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab',
|
|
73
|
+
'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen',
|
|
74
|
+
'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru',
|
|
75
|
+
'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown',
|
|
76
|
+
'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen',
|
|
77
|
+
'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray',
|
|
78
|
+
'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato',
|
|
79
|
+
'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow',
|
|
80
|
+
'yellowgreen' ], [ 'all-scroll', 'col-resize', 'crosshair', 'default',
|
|
81
|
+
'e-resize', 'hand', 'help', 'move', 'n-resize', 'ne-resize', 'no-drop',
|
|
82
|
+
'not-allowed', 'nw-resize', 'pointer', 'progress', 'row-resize',
|
|
83
|
+
's-resize', 'se-resize', 'sw-resize', 'text', 'vertical-text',
|
|
84
|
+
'w-resize', 'wait' ], [ '-moz-inline-box', '-moz-inline-stack',
|
|
85
|
+
'block', 'inline', 'inline-block', 'inline-table', 'list-item',
|
|
86
|
+
'run-in', 'table', 'table-caption', 'table-cell', 'table-column',
|
|
87
|
+
'table-column-group', 'table-footer-group', 'table-header-group',
|
|
88
|
+
'table-row', 'table-row-group' ], [ 'armenian', 'circle', 'decimal',
|
|
89
|
+
'decimal-leading-zero', 'disc', 'georgian', 'lower-alpha',
|
|
90
|
+
'lower-greek', 'lower-latin', 'lower-roman', 'square', 'upper-alpha',
|
|
91
|
+
'upper-latin', 'upper-roman' ], [ '100', '200', '300', '400', '500',
|
|
92
|
+
'600', '700', '800', '900', 'bold', 'bolder', 'lighter' ], [
|
|
93
|
+
'condensed', 'expanded', 'extra-condensed', 'extra-expanded',
|
|
94
|
+
'narrower', 'semi-condensed', 'semi-expanded', 'ultra-condensed',
|
|
95
|
+
'ultra-expanded', 'wider' ], [ 'behind', 'center-left', 'center-right',
|
|
96
|
+
'far-left', 'far-right', 'left-side', 'leftwards', 'right-side',
|
|
97
|
+
'rightwards' ], [ 'large', 'larger', 'small', 'smaller', 'x-large',
|
|
98
|
+
'x-small', 'xx-large', 'xx-small' ], [ '-moz-pre-wrap', '-o-pre-wrap',
|
|
99
|
+
'-pre-wrap', 'nowrap', 'pre', 'pre-line', 'pre-wrap' ], [ 'dashed',
|
|
100
|
+
'dotted', 'double', 'groove', 'outset', 'ridge', 'solid' ], [
|
|
101
|
+
'baseline', 'middle', 'sub', 'super', 'text-bottom', 'text-top' ], [
|
|
102
|
+
'caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar'
|
|
103
|
+
], [ 'fast', 'faster', 'slow', 'slower', 'x-fast', 'x-slow' ], [ 'above',
|
|
104
|
+
'below', 'higher', 'level', 'lower' ], [ 'border-box', 'contain',
|
|
105
|
+
'content-box', 'cover', 'padding-box' ], [ 'cursive', 'fantasy',
|
|
106
|
+
'monospace', 'sans-serif', 'serif' ], [ 'loud', 'silent', 'soft',
|
|
107
|
+
'x-loud', 'x-soft' ], [ 'no-repeat', 'repeat-x', 'repeat-y', 'round',
|
|
108
|
+
'space' ], [ 'blink', 'line-through', 'overline', 'underline' ], [
|
|
109
|
+
'high', 'low', 'x-high', 'x-low' ], [ 'absolute', 'relative', 'static'
|
|
110
|
+
], [ 'capitalize', 'lowercase', 'uppercase' ], [ 'child', 'female',
|
|
111
|
+
'male' ], [ 'bidi-override', 'embed' ], [ 'bottom', 'top' ], [ 'clip',
|
|
112
|
+
'ellipsis' ], [ 'continuous', 'digits' ], [ 'hide', 'show' ], [
|
|
113
|
+
'inside', 'outside' ], [ 'italic', 'oblique' ], [ 'left', 'right' ], [
|
|
114
|
+
'ltr', 'rtl' ], [ 'no-content', 'no-display' ], [ 'suppress',
|
|
115
|
+
'unrestricted' ], [ 'thick', 'thin' ], [ ',' ], [ '/' ], [ 'always' ],
|
|
116
|
+
[ 'auto' ], [ 'avoid' ], [ 'both' ], [ 'break-word' ], [ 'center' ], [
|
|
117
|
+
'code' ], [ 'collapse' ], [ 'fixed' ], [ 'hidden' ], [ 'inherit' ], [
|
|
118
|
+
'inset' ], [ 'invert' ], [ 'justify' ], [ 'local' ], [ 'medium' ], [
|
|
119
|
+
'mix' ], [ 'none' ], [ 'normal' ], [ 'once' ], [ 'repeat' ], [ 'scroll'
|
|
120
|
+
], [ 'separate' ], [ 'small-caps' ], [ 'spell-out' ], [ 'transparent' ],
|
|
121
|
+
[ 'visible' ] ];
|
|
122
|
+
return {
|
|
123
|
+
'-moz-border-radius': {
|
|
124
|
+
'cssExtra': c[ 0 ],
|
|
125
|
+
'cssPropBits': 5,
|
|
126
|
+
'cssLitGroup': [ L[ 36 ] ]
|
|
127
|
+
},
|
|
128
|
+
'-moz-border-radius-bottomleft': {
|
|
129
|
+
'cssExtra': c[ 0 ],
|
|
130
|
+
'cssPropBits': 5
|
|
131
|
+
},
|
|
132
|
+
'-moz-border-radius-bottomright': {
|
|
133
|
+
'cssExtra': c[ 0 ],
|
|
134
|
+
'cssPropBits': 5
|
|
135
|
+
},
|
|
136
|
+
'-moz-border-radius-topleft': {
|
|
137
|
+
'cssExtra': c[ 0 ],
|
|
138
|
+
'cssPropBits': 5
|
|
139
|
+
},
|
|
140
|
+
'-moz-border-radius-topright': {
|
|
141
|
+
'cssExtra': c[ 0 ],
|
|
142
|
+
'cssPropBits': 5
|
|
143
|
+
},
|
|
144
|
+
'-moz-box-shadow': {
|
|
145
|
+
'cssExtra': c[ 1 ],
|
|
146
|
+
'cssAlternates': [ 'boxShadow' ],
|
|
147
|
+
'cssPropBits': 7,
|
|
148
|
+
'cssLitGroup': [ L[ 0 ], L[ 35 ], L[ 48 ], L[ 54 ] ]
|
|
149
|
+
},
|
|
150
|
+
'-moz-opacity': {
|
|
151
|
+
'cssPropBits': 1,
|
|
152
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
153
|
+
},
|
|
154
|
+
'-moz-outline': {
|
|
155
|
+
'cssExtra': c[ 3 ],
|
|
156
|
+
'cssPropBits': 7,
|
|
157
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
158
|
+
49 ], L[ 52 ], L[ 54 ] ]
|
|
159
|
+
},
|
|
160
|
+
'-moz-outline-color': {
|
|
161
|
+
'cssExtra': c[ 2 ],
|
|
162
|
+
'cssPropBits': 2,
|
|
163
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 49 ] ]
|
|
164
|
+
},
|
|
165
|
+
'-moz-outline-style': {
|
|
166
|
+
'cssPropBits': 0,
|
|
167
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
168
|
+
},
|
|
169
|
+
'-moz-outline-width': {
|
|
170
|
+
'cssPropBits': 5,
|
|
171
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
172
|
+
},
|
|
173
|
+
'-o-text-overflow': {
|
|
174
|
+
'cssPropBits': 0,
|
|
175
|
+
'cssLitGroup': [ L[ 25 ] ]
|
|
176
|
+
},
|
|
177
|
+
'-webkit-border-bottom-left-radius': {
|
|
178
|
+
'cssExtra': c[ 0 ],
|
|
179
|
+
'cssPropBits': 5
|
|
180
|
+
},
|
|
181
|
+
'-webkit-border-bottom-right-radius': {
|
|
182
|
+
'cssExtra': c[ 0 ],
|
|
183
|
+
'cssPropBits': 5
|
|
184
|
+
},
|
|
185
|
+
'-webkit-border-radius': {
|
|
186
|
+
'cssExtra': c[ 0 ],
|
|
187
|
+
'cssPropBits': 5,
|
|
188
|
+
'cssLitGroup': [ L[ 36 ] ]
|
|
189
|
+
},
|
|
190
|
+
'-webkit-border-radius-bottom-left': {
|
|
191
|
+
'cssExtra': c[ 0 ],
|
|
192
|
+
'cssPropBits': 5
|
|
193
|
+
},
|
|
194
|
+
'-webkit-border-radius-bottom-right': {
|
|
195
|
+
'cssExtra': c[ 0 ],
|
|
196
|
+
'cssPropBits': 5
|
|
197
|
+
},
|
|
198
|
+
'-webkit-border-radius-top-left': {
|
|
199
|
+
'cssExtra': c[ 0 ],
|
|
200
|
+
'cssPropBits': 5
|
|
201
|
+
},
|
|
202
|
+
'-webkit-border-radius-top-right': {
|
|
203
|
+
'cssExtra': c[ 0 ],
|
|
204
|
+
'cssPropBits': 5
|
|
205
|
+
},
|
|
206
|
+
'-webkit-border-top-left-radius': {
|
|
207
|
+
'cssExtra': c[ 0 ],
|
|
208
|
+
'cssPropBits': 5
|
|
209
|
+
},
|
|
210
|
+
'-webkit-border-top-right-radius': {
|
|
211
|
+
'cssExtra': c[ 0 ],
|
|
212
|
+
'cssPropBits': 5
|
|
213
|
+
},
|
|
214
|
+
'-webkit-box-shadow': {
|
|
215
|
+
'cssExtra': c[ 1 ],
|
|
216
|
+
'cssAlternates': [ 'boxShadow' ],
|
|
217
|
+
'cssPropBits': 7,
|
|
218
|
+
'cssLitGroup': [ L[ 0 ], L[ 35 ], L[ 48 ], L[ 54 ] ]
|
|
219
|
+
},
|
|
220
|
+
'azimuth': {
|
|
221
|
+
'cssPropBits': 5,
|
|
222
|
+
'cssLitGroup': [ L[ 6 ], L[ 30 ], L[ 42 ], L[ 47 ] ]
|
|
223
|
+
},
|
|
224
|
+
'background': {
|
|
225
|
+
'cssExtra': RegExp('^ *(?:\\s*' + s[ 0 ] + '){0,2} *$', 'i'),
|
|
226
|
+
'cssPropBits': 23,
|
|
227
|
+
'cssLitGroup': [ L[ 0 ], L[ 14 ], L[ 17 ], L[ 24 ], L[ 30 ], L[ 35 ],
|
|
228
|
+
L[ 36 ], L[ 38 ], L[ 42 ], L[ 45 ], L[ 47 ], L[ 51 ], L[ 54 ], L[ 57
|
|
229
|
+
], L[ 58 ], L[ 62 ] ]
|
|
230
|
+
},
|
|
231
|
+
'background-attachment': {
|
|
232
|
+
'cssExtra': c[ 0 ],
|
|
233
|
+
'cssPropBits': 0,
|
|
234
|
+
'cssLitGroup': [ L[ 35 ], L[ 45 ], L[ 51 ], L[ 58 ] ]
|
|
235
|
+
},
|
|
236
|
+
'background-color': {
|
|
237
|
+
'cssExtra': c[ 2 ],
|
|
238
|
+
'cssPropBits': 130,
|
|
239
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 62 ] ]
|
|
240
|
+
},
|
|
241
|
+
'background-image': {
|
|
242
|
+
'cssExtra': c[ 0 ],
|
|
243
|
+
'cssPropBits': 16,
|
|
244
|
+
'cssLitGroup': [ L[ 35 ], L[ 54 ] ]
|
|
245
|
+
},
|
|
246
|
+
'background-position': {
|
|
247
|
+
'cssExtra': c[ 0 ],
|
|
248
|
+
'cssPropBits': 5,
|
|
249
|
+
'cssLitGroup': [ L[ 24 ], L[ 30 ], L[ 35 ], L[ 42 ] ]
|
|
250
|
+
},
|
|
251
|
+
'background-repeat': {
|
|
252
|
+
'cssExtra': c[ 0 ],
|
|
253
|
+
'cssPropBits': 0,
|
|
254
|
+
'cssLitGroup': [ L[ 17 ], L[ 35 ], L[ 57 ] ]
|
|
255
|
+
},
|
|
256
|
+
'border': {
|
|
257
|
+
'cssExtra': c[ 3 ],
|
|
258
|
+
'cssPropBits': 7,
|
|
259
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
260
|
+
52 ], L[ 54 ], L[ 62 ] ]
|
|
261
|
+
},
|
|
262
|
+
'border-bottom': {
|
|
263
|
+
'cssExtra': c[ 3 ],
|
|
264
|
+
'cssPropBits': 7,
|
|
265
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
266
|
+
52 ], L[ 54 ], L[ 62 ] ]
|
|
267
|
+
},
|
|
268
|
+
'border-bottom-color': {
|
|
269
|
+
'cssExtra': c[ 2 ],
|
|
270
|
+
'cssPropBits': 2,
|
|
271
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 62 ] ]
|
|
272
|
+
},
|
|
273
|
+
'border-bottom-left-radius': {
|
|
274
|
+
'cssExtra': c[ 0 ],
|
|
275
|
+
'cssPropBits': 5
|
|
276
|
+
},
|
|
277
|
+
'border-bottom-right-radius': {
|
|
278
|
+
'cssExtra': c[ 0 ],
|
|
279
|
+
'cssPropBits': 5
|
|
280
|
+
},
|
|
281
|
+
'border-bottom-style': {
|
|
282
|
+
'cssPropBits': 0,
|
|
283
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
284
|
+
},
|
|
285
|
+
'border-bottom-width': {
|
|
286
|
+
'cssPropBits': 5,
|
|
287
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
288
|
+
},
|
|
289
|
+
'border-collapse': {
|
|
290
|
+
'cssPropBits': 0,
|
|
291
|
+
'cssLitGroup': [ L[ 44 ], L[ 47 ], L[ 59 ] ]
|
|
292
|
+
},
|
|
293
|
+
'border-color': {
|
|
294
|
+
'cssExtra': RegExp('^ *(?:\\s*' + s[ 0 ] + '){1,4} *$', 'i'),
|
|
295
|
+
'cssPropBits': 2,
|
|
296
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 62 ] ]
|
|
297
|
+
},
|
|
298
|
+
'border-left': {
|
|
299
|
+
'cssExtra': c[ 3 ],
|
|
300
|
+
'cssPropBits': 7,
|
|
301
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
302
|
+
52 ], L[ 54 ], L[ 62 ] ]
|
|
303
|
+
},
|
|
304
|
+
'border-left-color': {
|
|
305
|
+
'cssExtra': c[ 2 ],
|
|
306
|
+
'cssPropBits': 2,
|
|
307
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 62 ] ]
|
|
308
|
+
},
|
|
309
|
+
'border-left-style': {
|
|
310
|
+
'cssPropBits': 0,
|
|
311
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
312
|
+
},
|
|
313
|
+
'border-left-width': {
|
|
314
|
+
'cssPropBits': 5,
|
|
315
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
316
|
+
},
|
|
317
|
+
'border-radius': {
|
|
318
|
+
'cssExtra': c[ 0 ],
|
|
319
|
+
'cssPropBits': 5,
|
|
320
|
+
'cssLitGroup': [ L[ 36 ] ]
|
|
321
|
+
},
|
|
322
|
+
'border-right': {
|
|
323
|
+
'cssExtra': c[ 3 ],
|
|
324
|
+
'cssPropBits': 7,
|
|
325
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
326
|
+
52 ], L[ 54 ], L[ 62 ] ]
|
|
327
|
+
},
|
|
328
|
+
'border-right-color': {
|
|
329
|
+
'cssExtra': c[ 2 ],
|
|
330
|
+
'cssPropBits': 2,
|
|
331
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 62 ] ]
|
|
332
|
+
},
|
|
333
|
+
'border-right-style': {
|
|
334
|
+
'cssPropBits': 0,
|
|
335
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
336
|
+
},
|
|
337
|
+
'border-right-width': {
|
|
338
|
+
'cssPropBits': 5,
|
|
339
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
340
|
+
},
|
|
341
|
+
'border-spacing': {
|
|
342
|
+
'cssExtra': c[ 0 ],
|
|
343
|
+
'cssPropBits': 5,
|
|
344
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
345
|
+
},
|
|
346
|
+
'border-style': {
|
|
347
|
+
'cssPropBits': 0,
|
|
348
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
349
|
+
},
|
|
350
|
+
'border-top': {
|
|
351
|
+
'cssExtra': c[ 3 ],
|
|
352
|
+
'cssPropBits': 7,
|
|
353
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
354
|
+
52 ], L[ 54 ], L[ 62 ] ]
|
|
355
|
+
},
|
|
356
|
+
'border-top-color': {
|
|
357
|
+
'cssExtra': c[ 2 ],
|
|
358
|
+
'cssPropBits': 2,
|
|
359
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 62 ] ]
|
|
360
|
+
},
|
|
361
|
+
'border-top-left-radius': {
|
|
362
|
+
'cssExtra': c[ 0 ],
|
|
363
|
+
'cssPropBits': 5
|
|
364
|
+
},
|
|
365
|
+
'border-top-right-radius': {
|
|
366
|
+
'cssExtra': c[ 0 ],
|
|
367
|
+
'cssPropBits': 5
|
|
368
|
+
},
|
|
369
|
+
'border-top-style': {
|
|
370
|
+
'cssPropBits': 0,
|
|
371
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
372
|
+
},
|
|
373
|
+
'border-top-width': {
|
|
374
|
+
'cssPropBits': 5,
|
|
375
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
376
|
+
},
|
|
377
|
+
'border-width': {
|
|
378
|
+
'cssPropBits': 5,
|
|
379
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
380
|
+
},
|
|
381
|
+
'bottom': {
|
|
382
|
+
'cssPropBits': 5,
|
|
383
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
384
|
+
},
|
|
385
|
+
'box-shadow': {
|
|
386
|
+
'cssExtra': c[ 1 ],
|
|
387
|
+
'cssPropBits': 7,
|
|
388
|
+
'cssLitGroup': [ L[ 0 ], L[ 35 ], L[ 48 ], L[ 54 ] ]
|
|
389
|
+
},
|
|
390
|
+
'caption-side': {
|
|
391
|
+
'cssPropBits': 0,
|
|
392
|
+
'cssLitGroup': [ L[ 24 ], L[ 47 ] ]
|
|
393
|
+
},
|
|
394
|
+
'clear': {
|
|
395
|
+
'cssPropBits': 0,
|
|
396
|
+
'cssLitGroup': [ L[ 30 ], L[ 40 ], L[ 47 ], L[ 54 ] ]
|
|
397
|
+
},
|
|
398
|
+
'clip': {
|
|
399
|
+
'cssExtra':
|
|
400
|
+
/^ *\s*rect\(\s*(?:0|[+\-]?\d+(?:\.\d+)?(?:[cem]m|ex|in|p[ctx])|auto)\s*,\s*(?:0|[+\-]?\d+(?:\.\d+)?(?:[cem]m|ex|in|p[ctx])|auto)\s*,\s*(?:0|[+\-]?\d+(?:\.\d+)?(?:[cem]m|ex|in|p[ctx])|auto)\s*,\s*(?:0|[+\-]?\d+(?:\.\d+)?(?:[cem]m|ex|in|p[ctx])|auto) *\) *$/i,
|
|
401
|
+
'cssPropBits': 0,
|
|
402
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
403
|
+
},
|
|
404
|
+
'color': {
|
|
405
|
+
'cssExtra': c[ 2 ],
|
|
406
|
+
'cssPropBits': 130,
|
|
407
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ] ]
|
|
408
|
+
},
|
|
409
|
+
'content': { 'cssPropBits': 0 },
|
|
410
|
+
'counter-increment': {
|
|
411
|
+
'cssExtra': c[ 0 ],
|
|
412
|
+
'cssPropBits': 5,
|
|
413
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
414
|
+
},
|
|
415
|
+
'counter-reset': {
|
|
416
|
+
'cssExtra': c[ 0 ],
|
|
417
|
+
'cssPropBits': 5,
|
|
418
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
419
|
+
},
|
|
420
|
+
'cue': {
|
|
421
|
+
'cssPropBits': 16,
|
|
422
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
423
|
+
},
|
|
424
|
+
'cue-after': {
|
|
425
|
+
'cssPropBits': 16,
|
|
426
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
427
|
+
},
|
|
428
|
+
'cue-before': {
|
|
429
|
+
'cssPropBits': 16,
|
|
430
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
431
|
+
},
|
|
432
|
+
'cursor': {
|
|
433
|
+
'cssExtra': c[ 0 ],
|
|
434
|
+
'cssPropBits': 144,
|
|
435
|
+
'cssLitGroup': [ L[ 1 ], L[ 35 ], L[ 38 ], L[ 47 ] ]
|
|
436
|
+
},
|
|
437
|
+
'direction': {
|
|
438
|
+
'cssPropBits': 0,
|
|
439
|
+
'cssLitGroup': [ L[ 31 ], L[ 47 ] ]
|
|
440
|
+
},
|
|
441
|
+
'display': {
|
|
442
|
+
'cssPropBits': 32,
|
|
443
|
+
'cssLitGroup': [ L[ 2 ], L[ 47 ], L[ 54 ] ]
|
|
444
|
+
},
|
|
445
|
+
'elevation': {
|
|
446
|
+
'cssPropBits': 5,
|
|
447
|
+
'cssLitGroup': [ L[ 13 ], L[ 47 ] ]
|
|
448
|
+
},
|
|
449
|
+
'empty-cells': {
|
|
450
|
+
'cssPropBits': 0,
|
|
451
|
+
'cssLitGroup': [ L[ 27 ], L[ 47 ] ]
|
|
452
|
+
},
|
|
453
|
+
'filter': {
|
|
454
|
+
'cssExtra':
|
|
455
|
+
/^ *(?:\s*alpha\(\s*opacity\s*=\s*(?:0|\d+(?:\.\d+)?%|[+\-]?\d+(?:\.\d+)?) *\))+ *$/i,
|
|
456
|
+
'cssPropBits': 32
|
|
457
|
+
},
|
|
458
|
+
'float': {
|
|
459
|
+
'cssAlternates': [ 'cssFloat', 'styleFloat' ],
|
|
460
|
+
'cssPropBits': 32,
|
|
461
|
+
'cssLitGroup': [ L[ 30 ], L[ 47 ], L[ 54 ] ]
|
|
462
|
+
},
|
|
463
|
+
'font': {
|
|
464
|
+
'cssExtra': c[ 0 ],
|
|
465
|
+
'cssPropBits': 9,
|
|
466
|
+
'cssLitGroup': [ L[ 4 ], L[ 7 ], L[ 11 ], L[ 15 ], L[ 29 ], L[ 35 ], L[
|
|
467
|
+
36 ], L[ 47 ], L[ 52 ], L[ 55 ], L[ 60 ] ]
|
|
468
|
+
},
|
|
469
|
+
'font-family': {
|
|
470
|
+
'cssExtra': c[ 0 ],
|
|
471
|
+
'cssPropBits': 8,
|
|
472
|
+
'cssLitGroup': [ L[ 15 ], L[ 35 ], L[ 47 ] ]
|
|
473
|
+
},
|
|
474
|
+
'font-size': {
|
|
475
|
+
'cssPropBits': 1,
|
|
476
|
+
'cssLitGroup': [ L[ 7 ], L[ 47 ], L[ 52 ] ]
|
|
477
|
+
},
|
|
478
|
+
'font-stretch': {
|
|
479
|
+
'cssPropBits': 0,
|
|
480
|
+
'cssLitGroup': [ L[ 5 ], L[ 55 ] ]
|
|
481
|
+
},
|
|
482
|
+
'font-style': {
|
|
483
|
+
'cssPropBits': 0,
|
|
484
|
+
'cssLitGroup': [ L[ 29 ], L[ 47 ], L[ 55 ] ]
|
|
485
|
+
},
|
|
486
|
+
'font-variant': {
|
|
487
|
+
'cssPropBits': 0,
|
|
488
|
+
'cssLitGroup': [ L[ 47 ], L[ 55 ], L[ 60 ] ]
|
|
489
|
+
},
|
|
490
|
+
'font-weight': {
|
|
491
|
+
'cssPropBits': 0,
|
|
492
|
+
'cssLitGroup': [ L[ 4 ], L[ 47 ], L[ 55 ] ],
|
|
493
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
494
|
+
'cssLitNumeric': true
|
|
495
|
+
// ##### END: MODIFIED BY SAP
|
|
496
|
+
},
|
|
497
|
+
'height': {
|
|
498
|
+
'cssPropBits': 37,
|
|
499
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
500
|
+
},
|
|
501
|
+
'left': {
|
|
502
|
+
'cssPropBits': 37,
|
|
503
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
504
|
+
},
|
|
505
|
+
'letter-spacing': {
|
|
506
|
+
'cssPropBits': 5,
|
|
507
|
+
'cssLitGroup': [ L[ 47 ], L[ 55 ] ]
|
|
508
|
+
},
|
|
509
|
+
'line-height': {
|
|
510
|
+
'cssPropBits': 1,
|
|
511
|
+
'cssLitGroup': [ L[ 47 ], L[ 55 ] ]
|
|
512
|
+
},
|
|
513
|
+
'list-style': {
|
|
514
|
+
'cssPropBits': 16,
|
|
515
|
+
'cssLitGroup': [ L[ 3 ], L[ 28 ], L[ 47 ], L[ 54 ] ]
|
|
516
|
+
},
|
|
517
|
+
'list-style-image': {
|
|
518
|
+
'cssPropBits': 16,
|
|
519
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
520
|
+
},
|
|
521
|
+
'list-style-position': {
|
|
522
|
+
'cssPropBits': 0,
|
|
523
|
+
'cssLitGroup': [ L[ 28 ], L[ 47 ] ]
|
|
524
|
+
},
|
|
525
|
+
'list-style-type': {
|
|
526
|
+
'cssPropBits': 0,
|
|
527
|
+
'cssLitGroup': [ L[ 3 ], L[ 47 ], L[ 54 ] ]
|
|
528
|
+
},
|
|
529
|
+
'margin': {
|
|
530
|
+
'cssPropBits': 5,
|
|
531
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
532
|
+
},
|
|
533
|
+
'margin-bottom': {
|
|
534
|
+
'cssPropBits': 5,
|
|
535
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
536
|
+
},
|
|
537
|
+
'margin-left': {
|
|
538
|
+
'cssPropBits': 5,
|
|
539
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
540
|
+
},
|
|
541
|
+
'margin-right': {
|
|
542
|
+
'cssPropBits': 5,
|
|
543
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
544
|
+
},
|
|
545
|
+
'margin-top': {
|
|
546
|
+
'cssPropBits': 5,
|
|
547
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
548
|
+
},
|
|
549
|
+
'max-height': {
|
|
550
|
+
'cssPropBits': 1,
|
|
551
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ], L[ 54 ] ]
|
|
552
|
+
},
|
|
553
|
+
'max-width': {
|
|
554
|
+
'cssPropBits': 1,
|
|
555
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ], L[ 54 ] ]
|
|
556
|
+
},
|
|
557
|
+
'min-height': {
|
|
558
|
+
'cssPropBits': 1,
|
|
559
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
560
|
+
},
|
|
561
|
+
'min-width': {
|
|
562
|
+
'cssPropBits': 1,
|
|
563
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
564
|
+
},
|
|
565
|
+
'opacity': {
|
|
566
|
+
'cssPropBits': 33,
|
|
567
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
568
|
+
},
|
|
569
|
+
'outline': {
|
|
570
|
+
'cssExtra': c[ 3 ],
|
|
571
|
+
'cssPropBits': 7,
|
|
572
|
+
'cssLitGroup': [ L[ 0 ], L[ 9 ], L[ 34 ], L[ 46 ], L[ 47 ], L[ 48 ], L[
|
|
573
|
+
49 ], L[ 52 ], L[ 54 ] ]
|
|
574
|
+
},
|
|
575
|
+
'outline-color': {
|
|
576
|
+
'cssExtra': c[ 2 ],
|
|
577
|
+
'cssPropBits': 2,
|
|
578
|
+
'cssLitGroup': [ L[ 0 ], L[ 47 ], L[ 49 ] ]
|
|
579
|
+
},
|
|
580
|
+
'outline-style': {
|
|
581
|
+
'cssPropBits': 0,
|
|
582
|
+
'cssLitGroup': [ L[ 9 ], L[ 46 ], L[ 47 ], L[ 48 ], L[ 54 ] ]
|
|
583
|
+
},
|
|
584
|
+
'outline-width': {
|
|
585
|
+
'cssPropBits': 5,
|
|
586
|
+
'cssLitGroup': [ L[ 34 ], L[ 47 ], L[ 52 ] ]
|
|
587
|
+
},
|
|
588
|
+
'overflow': {
|
|
589
|
+
'cssPropBits': 32,
|
|
590
|
+
'cssLitGroup': [ L[ 38 ], L[ 46 ], L[ 47 ], L[ 58 ], L[ 63 ] ]
|
|
591
|
+
},
|
|
592
|
+
'overflow-x': {
|
|
593
|
+
'cssPropBits': 0,
|
|
594
|
+
'cssLitGroup': [ L[ 32 ], L[ 38 ], L[ 46 ], L[ 58 ], L[ 63 ] ]
|
|
595
|
+
},
|
|
596
|
+
'overflow-y': {
|
|
597
|
+
'cssPropBits': 0,
|
|
598
|
+
'cssLitGroup': [ L[ 32 ], L[ 38 ], L[ 46 ], L[ 58 ], L[ 63 ] ]
|
|
599
|
+
},
|
|
600
|
+
'padding': {
|
|
601
|
+
'cssPropBits': 1,
|
|
602
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
603
|
+
},
|
|
604
|
+
'padding-bottom': {
|
|
605
|
+
'cssPropBits': 33,
|
|
606
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
607
|
+
},
|
|
608
|
+
'padding-left': {
|
|
609
|
+
'cssPropBits': 33,
|
|
610
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
611
|
+
},
|
|
612
|
+
'padding-right': {
|
|
613
|
+
'cssPropBits': 33,
|
|
614
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
615
|
+
},
|
|
616
|
+
'padding-top': {
|
|
617
|
+
'cssPropBits': 33,
|
|
618
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
619
|
+
},
|
|
620
|
+
'page-break-after': {
|
|
621
|
+
'cssPropBits': 0,
|
|
622
|
+
'cssLitGroup': [ L[ 30 ], L[ 37 ], L[ 38 ], L[ 39 ], L[ 47 ] ]
|
|
623
|
+
},
|
|
624
|
+
'page-break-before': {
|
|
625
|
+
'cssPropBits': 0,
|
|
626
|
+
'cssLitGroup': [ L[ 30 ], L[ 37 ], L[ 38 ], L[ 39 ], L[ 47 ] ]
|
|
627
|
+
},
|
|
628
|
+
'page-break-inside': {
|
|
629
|
+
'cssPropBits': 0,
|
|
630
|
+
'cssLitGroup': [ L[ 38 ], L[ 39 ], L[ 47 ] ]
|
|
631
|
+
},
|
|
632
|
+
'pause': {
|
|
633
|
+
'cssPropBits': 5,
|
|
634
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
635
|
+
},
|
|
636
|
+
'pause-after': {
|
|
637
|
+
'cssPropBits': 5,
|
|
638
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
639
|
+
},
|
|
640
|
+
'pause-before': {
|
|
641
|
+
'cssPropBits': 5,
|
|
642
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
643
|
+
},
|
|
644
|
+
'pitch': {
|
|
645
|
+
'cssPropBits': 5,
|
|
646
|
+
'cssLitGroup': [ L[ 19 ], L[ 47 ], L[ 52 ] ]
|
|
647
|
+
},
|
|
648
|
+
'pitch-range': {
|
|
649
|
+
'cssPropBits': 5,
|
|
650
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
651
|
+
},
|
|
652
|
+
'play-during': {
|
|
653
|
+
'cssExtra': c[ 0 ],
|
|
654
|
+
'cssPropBits': 16,
|
|
655
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ], L[ 53 ], L[ 54 ], L[ 57 ] ]
|
|
656
|
+
},
|
|
657
|
+
'position': {
|
|
658
|
+
'cssPropBits': 32,
|
|
659
|
+
'cssLitGroup': [ L[ 20 ], L[ 47 ] ]
|
|
660
|
+
},
|
|
661
|
+
'quotes': {
|
|
662
|
+
'cssExtra': c[ 0 ],
|
|
663
|
+
'cssPropBits': 0,
|
|
664
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ] ]
|
|
665
|
+
},
|
|
666
|
+
'richness': {
|
|
667
|
+
'cssPropBits': 5,
|
|
668
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
669
|
+
},
|
|
670
|
+
'right': {
|
|
671
|
+
'cssPropBits': 37,
|
|
672
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
673
|
+
},
|
|
674
|
+
'speak': {
|
|
675
|
+
'cssPropBits': 0,
|
|
676
|
+
'cssLitGroup': [ L[ 47 ], L[ 54 ], L[ 55 ], L[ 61 ] ]
|
|
677
|
+
},
|
|
678
|
+
'speak-header': {
|
|
679
|
+
'cssPropBits': 0,
|
|
680
|
+
'cssLitGroup': [ L[ 37 ], L[ 47 ], L[ 56 ] ]
|
|
681
|
+
},
|
|
682
|
+
'speak-numeral': {
|
|
683
|
+
'cssPropBits': 0,
|
|
684
|
+
'cssLitGroup': [ L[ 26 ], L[ 47 ] ]
|
|
685
|
+
},
|
|
686
|
+
'speak-punctuation': {
|
|
687
|
+
'cssPropBits': 0,
|
|
688
|
+
'cssLitGroup': [ L[ 43 ], L[ 47 ], L[ 54 ] ]
|
|
689
|
+
},
|
|
690
|
+
'speech-rate': {
|
|
691
|
+
'cssPropBits': 5,
|
|
692
|
+
'cssLitGroup': [ L[ 12 ], L[ 47 ], L[ 52 ] ]
|
|
693
|
+
},
|
|
694
|
+
'stress': {
|
|
695
|
+
'cssPropBits': 5,
|
|
696
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
697
|
+
},
|
|
698
|
+
'table-layout': {
|
|
699
|
+
'cssPropBits': 0,
|
|
700
|
+
'cssLitGroup': [ L[ 38 ], L[ 45 ], L[ 47 ] ]
|
|
701
|
+
},
|
|
702
|
+
'text-align': {
|
|
703
|
+
'cssPropBits': 0,
|
|
704
|
+
'cssLitGroup': [ L[ 30 ], L[ 42 ], L[ 47 ], L[ 50 ] ]
|
|
705
|
+
},
|
|
706
|
+
'text-decoration': {
|
|
707
|
+
'cssPropBits': 0,
|
|
708
|
+
'cssLitGroup': [ L[ 18 ], L[ 47 ], L[ 54 ] ]
|
|
709
|
+
},
|
|
710
|
+
'text-indent': {
|
|
711
|
+
'cssPropBits': 5,
|
|
712
|
+
'cssLitGroup': [ L[ 47 ] ]
|
|
713
|
+
},
|
|
714
|
+
'text-overflow': {
|
|
715
|
+
'cssPropBits': 0,
|
|
716
|
+
'cssLitGroup': [ L[ 25 ] ]
|
|
717
|
+
},
|
|
718
|
+
'text-shadow': {
|
|
719
|
+
'cssExtra': c[ 1 ],
|
|
720
|
+
'cssPropBits': 7,
|
|
721
|
+
'cssLitGroup': [ L[ 0 ], L[ 35 ], L[ 48 ], L[ 54 ] ]
|
|
722
|
+
},
|
|
723
|
+
'text-transform': {
|
|
724
|
+
'cssPropBits': 0,
|
|
725
|
+
'cssLitGroup': [ L[ 21 ], L[ 47 ], L[ 54 ] ]
|
|
726
|
+
},
|
|
727
|
+
'text-wrap': {
|
|
728
|
+
'cssPropBits': 0,
|
|
729
|
+
'cssLitGroup': [ L[ 33 ], L[ 54 ], L[ 55 ] ]
|
|
730
|
+
},
|
|
731
|
+
'top': {
|
|
732
|
+
'cssPropBits': 37,
|
|
733
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
734
|
+
},
|
|
735
|
+
'unicode-bidi': {
|
|
736
|
+
'cssPropBits': 0,
|
|
737
|
+
'cssLitGroup': [ L[ 23 ], L[ 47 ], L[ 55 ] ]
|
|
738
|
+
},
|
|
739
|
+
'vertical-align': {
|
|
740
|
+
'cssPropBits': 5,
|
|
741
|
+
'cssLitGroup': [ L[ 10 ], L[ 24 ], L[ 47 ] ]
|
|
742
|
+
},
|
|
743
|
+
'visibility': {
|
|
744
|
+
'cssPropBits': 32,
|
|
745
|
+
'cssLitGroup': [ L[ 44 ], L[ 46 ], L[ 47 ], L[ 63 ] ]
|
|
746
|
+
},
|
|
747
|
+
'voice-family': {
|
|
748
|
+
'cssExtra': c[ 0 ],
|
|
749
|
+
'cssPropBits': 8,
|
|
750
|
+
'cssLitGroup': [ L[ 22 ], L[ 35 ], L[ 47 ] ]
|
|
751
|
+
},
|
|
752
|
+
'volume': {
|
|
753
|
+
'cssPropBits': 1,
|
|
754
|
+
'cssLitGroup': [ L[ 16 ], L[ 47 ], L[ 52 ] ]
|
|
755
|
+
},
|
|
756
|
+
'white-space': {
|
|
757
|
+
'cssPropBits': 0,
|
|
758
|
+
'cssLitGroup': [ L[ 8 ], L[ 47 ], L[ 55 ] ]
|
|
759
|
+
},
|
|
760
|
+
'width': {
|
|
761
|
+
'cssPropBits': 33,
|
|
762
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
763
|
+
},
|
|
764
|
+
'word-spacing': {
|
|
765
|
+
'cssPropBits': 5,
|
|
766
|
+
'cssLitGroup': [ L[ 47 ], L[ 55 ] ]
|
|
767
|
+
},
|
|
768
|
+
'word-wrap': {
|
|
769
|
+
'cssPropBits': 0,
|
|
770
|
+
'cssLitGroup': [ L[ 41 ], L[ 55 ] ]
|
|
771
|
+
},
|
|
772
|
+
'z-index': {
|
|
773
|
+
'cssPropBits': 69,
|
|
774
|
+
'cssLitGroup': [ L[ 38 ], L[ 47 ] ]
|
|
775
|
+
},
|
|
776
|
+
'zoom': {
|
|
777
|
+
'cssPropBits': 1,
|
|
778
|
+
'cssLitGroup': [ L[ 55 ] ]
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
})();
|
|
782
|
+
if (typeof window !== 'undefined') {
|
|
783
|
+
window['cssSchema'] = cssSchema;
|
|
784
|
+
}
|
|
785
|
+
// Copyright (C) 2011 Google Inc.
|
|
786
|
+
//
|
|
787
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
788
|
+
// you may not use this file except in compliance with the License.
|
|
789
|
+
// You may obtain a copy of the License at
|
|
790
|
+
//
|
|
791
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
792
|
+
//
|
|
793
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
794
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
795
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
796
|
+
// See the License for the specific language governing permissions and
|
|
797
|
+
// limitations under the License.
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* A lexical scannar for CSS3 as defined at http://www.w3.org/TR/css3-syntax .
|
|
801
|
+
*
|
|
802
|
+
* @author Mike Samuel <mikesamuel@gmail.com>
|
|
803
|
+
* \@provides lexCss, decodeCss
|
|
804
|
+
* \@overrides window
|
|
805
|
+
*/
|
|
806
|
+
|
|
807
|
+
var lexCss;
|
|
808
|
+
var decodeCss;
|
|
809
|
+
|
|
810
|
+
(function () {
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Decodes an escape sequence as specified in CSS3 section 4.1.
|
|
814
|
+
* http://www.w3.org/TR/css3-syntax/#characters
|
|
815
|
+
* @private
|
|
816
|
+
*/
|
|
817
|
+
function decodeCssEscape(s) {
|
|
818
|
+
var i = parseInt(s.substring(1), 16);
|
|
819
|
+
// If parseInt didn't find a hex diigt, it returns NaN so return the
|
|
820
|
+
// escaped character.
|
|
821
|
+
// Otherwise, parseInt will stop at the first non-hex digit so there's no
|
|
822
|
+
// need to worry about trailing whitespace.
|
|
823
|
+
if (i > 0xffff) {
|
|
824
|
+
// A supplemental codepoint.
|
|
825
|
+
return i -= 0x10000,
|
|
826
|
+
String.fromCharCode(
|
|
827
|
+
0xd800 + (i >> 10),
|
|
828
|
+
0xdc00 + (i & 0x3FF));
|
|
829
|
+
} else if (i == i) {
|
|
830
|
+
return String.fromCharCode(i);
|
|
831
|
+
} else if (s[1] < ' ') {
|
|
832
|
+
// "a backslash followed by a newline is ignored".
|
|
833
|
+
return '';
|
|
834
|
+
} else {
|
|
835
|
+
return s[1];
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Returns an equivalent CSS string literal given plain text: foo -> "foo".
|
|
841
|
+
* @private
|
|
842
|
+
*/
|
|
843
|
+
function escapeCssString(s, replacer) {
|
|
844
|
+
return '"' + s.replace(/[\u0000-\u001f\\\"<>]/g, replacer) + '"';
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Maps chars to CSS escaped equivalents: "\n" -> "\\a ".
|
|
849
|
+
* @private
|
|
850
|
+
*/
|
|
851
|
+
function escapeCssStrChar(ch) {
|
|
852
|
+
return cssStrChars[ch]
|
|
853
|
+
|| (cssStrChars[ch] = '\\' + ch.charCodeAt(0).toString(16) + ' ');
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Maps chars to URI escaped equivalents: "\n" -> "%0a".
|
|
858
|
+
* @private
|
|
859
|
+
*/
|
|
860
|
+
function escapeCssUrlChar(ch) {
|
|
861
|
+
return cssUrlChars[ch]
|
|
862
|
+
|| (cssUrlChars[ch] = (ch < '\x10' ? '%0' : '%')
|
|
863
|
+
+ ch.charCodeAt(0).toString(16));
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Mapping of CSS special characters to escaped equivalents.
|
|
868
|
+
* @private
|
|
869
|
+
*/
|
|
870
|
+
var cssStrChars = {
|
|
871
|
+
'\\': '\\\\'
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Mapping of CSS special characters to URL-escaped equivalents.
|
|
876
|
+
* @private
|
|
877
|
+
*/
|
|
878
|
+
var cssUrlChars = {
|
|
879
|
+
'\\': '%5c'
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
// The comments below are copied from the CSS3 module syntax at
|
|
883
|
+
// http://www.w3.org/TR/css3-syntax .
|
|
884
|
+
// These string constants minify out when this is run-through closure
|
|
885
|
+
// compiler.
|
|
886
|
+
// Rules that have been adapted have comments prefixed with "Diff:", and
|
|
887
|
+
// where rules have been combined to avoid back-tracking in the regex engine
|
|
888
|
+
// or to work around limitations, there is a comment prefixed with
|
|
889
|
+
// "NewRule:".
|
|
890
|
+
|
|
891
|
+
// In the below, we assume CRLF and CR have been normalize to CR.
|
|
892
|
+
|
|
893
|
+
// wc ::= #x9 | #xA | #xC | #xD | #x20
|
|
894
|
+
var WC = '[\\t\\n\\f ]';
|
|
895
|
+
// w ::= wc*
|
|
896
|
+
var W = WC + '*';
|
|
897
|
+
// nl ::= #xA | #xD #xA | #xD | #xC
|
|
898
|
+
var NL = '[\\n\\f]';
|
|
899
|
+
// nonascii ::= [#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
|
|
900
|
+
// NewRule: Supplemental codepoints are represented as surrogate pairs in JS.
|
|
901
|
+
var SURROGATE_PAIR = '[\\ud800-\\udbff][\\udc00-\\udfff]';
|
|
902
|
+
var NONASCII = '[\\u0080-\\ud7ff\\ue000-\\ufffd]|' + SURROGATE_PAIR;
|
|
903
|
+
// unicode ::= '\' [0-9a-fA-F]{1,6} wc?
|
|
904
|
+
// NewRule: No point in having ESCAPE do (\\x|\\y)
|
|
905
|
+
var UNICODE_TAIL = '[0-9a-fA-F]{1,6}' + WC + '?';
|
|
906
|
+
var UNICODE = '\\\\' + UNICODE_TAIL;
|
|
907
|
+
// escape ::= unicode
|
|
908
|
+
// | '\' [#x20-#x7E#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
|
|
909
|
+
// NewRule: Below we use escape tail to efficiently match an escape or a
|
|
910
|
+
// line continuation so we can decode string content.
|
|
911
|
+
var ESCAPE_TAIL = '(?:' + UNICODE_TAIL
|
|
912
|
+
+ '|[\\u0020-\\u007e\\u0080-\\ud7ff\\ue000\\ufffd]|'
|
|
913
|
+
+ SURROGATE_PAIR + ')';
|
|
914
|
+
var ESCAPE = '\\\\' + ESCAPE_TAIL;
|
|
915
|
+
// urlchar ::= [#x9#x21#x23-#x26#x28-#x7E] | nonascii | escape
|
|
916
|
+
var URLCHAR = '(?:[\\t\\x21\\x23-\\x26\\x28-\\x5b\\x5d-\\x7e]|'
|
|
917
|
+
+ NONASCII + '|' + ESCAPE + ')';
|
|
918
|
+
// stringchar ::= urlchar | #x20 | '\' nl
|
|
919
|
+
// We ignore mismatched surrogate pairs inside strings, so stringchar
|
|
920
|
+
// simplifies to a non-(quote|newline|backslash) or backslash any.
|
|
921
|
+
// Since we normalize CRLF to a single code-unit, there is no special
|
|
922
|
+
// handling needed for '\\' + CRLF.
|
|
923
|
+
var STRINGCHAR = '[^\'"\\n\\f\\\\]|\\\\[\\s\\S]';
|
|
924
|
+
// string ::= '"' (stringchar | "'")* '"' | "'" (stringchar | '"')* "'"
|
|
925
|
+
var STRING = '"(?:\'|' + STRINGCHAR + ')*"'
|
|
926
|
+
+ '|\'(?:\"|' + STRINGCHAR + ')*\'';
|
|
927
|
+
// num ::= [0-9]+ | [0-9]* '.' [0-9]+
|
|
928
|
+
// Diff: We attach signs to num tokens.
|
|
929
|
+
var NUM = '[-+]?(?:[0-9]+(?:[.][0-9]+)?|[.][0-9]+)';
|
|
930
|
+
// nmstart ::= [a-zA-Z] | '_' | nonascii | escape
|
|
931
|
+
var NMSTART = '(?:[a-zA-Z_]|' + NONASCII + '|' + ESCAPE + ')';
|
|
932
|
+
// nmchar ::= [a-zA-Z0-9] | '-' | '_' | nonascii | escape
|
|
933
|
+
var NMCHAR = '(?:[a-zA-Z0-9_-]|' + NONASCII + '|' + ESCAPE + ')';
|
|
934
|
+
// name ::= nmchar+
|
|
935
|
+
var NAME = NMCHAR + '+';
|
|
936
|
+
// ident ::= '-'? nmstart nmchar*
|
|
937
|
+
var IDENT = '-?' + NMSTART + NMCHAR + '*';
|
|
938
|
+
|
|
939
|
+
// ATKEYWORD ::= '@' ident
|
|
940
|
+
var ATKEYWORD = '@' + IDENT;
|
|
941
|
+
// HASH ::= '#' name
|
|
942
|
+
var HASH = '#' + NAME;
|
|
943
|
+
// NUMBER ::= num
|
|
944
|
+
var NUMBER = NUM;
|
|
945
|
+
|
|
946
|
+
// NewRule: union of IDENT, ATKEYWORD, HASH, but excluding #[0-9].
|
|
947
|
+
var WORD_TERM = '(?:@?-?' + NMSTART + '|#)' + NMCHAR + '*';
|
|
948
|
+
|
|
949
|
+
// PERCENTAGE ::= num '%'
|
|
950
|
+
var PERCENTAGE = NUM + '%';
|
|
951
|
+
// DIMENSION ::= num ident
|
|
952
|
+
var DIMENSION = NUM + IDENT;
|
|
953
|
+
var NUMERIC_VALUE = NUM + '(?:%|' + IDENT + ')?';
|
|
954
|
+
// URI ::= "url(" w (string | urlchar* ) w ")"
|
|
955
|
+
var URI = 'url[(]' + W + '(?:' + STRING + '|' + URLCHAR + '*)' + W + '[)]';
|
|
956
|
+
// UNICODE-RANGE ::= "U+" [0-9A-F?]{1,6} ('-' [0-9A-F]{1,6})?
|
|
957
|
+
var UNICODE_RANGE = 'U[+][0-9A-F?]{1,6}(?:-[0-9A-F]{1,6})?';
|
|
958
|
+
// CDO ::= "<\!--"
|
|
959
|
+
var CDO = '<\!--';
|
|
960
|
+
// CDC ::= "-->"
|
|
961
|
+
var CDC = '-->';
|
|
962
|
+
// S ::= wc+
|
|
963
|
+
var S = WC + '+';
|
|
964
|
+
// COMMENT ::= "/*" [^*]* '*'+ ([^/] [^*]* '*'+)* "/"
|
|
965
|
+
// Diff: recognizes // comments.
|
|
966
|
+
var COMMENT = '/(?:[*][^*]*[*]+(?:[^/][^*]*[*]+)*/|/[^\\n\\f]*)';
|
|
967
|
+
// FUNCTION ::= ident '('
|
|
968
|
+
// Diff: We exclude url explicitly.
|
|
969
|
+
// TODO: should we be tolerant of "fn ("?
|
|
970
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
971
|
+
// Avoid risk of 'catastrophic backtracking' when unicode escapes are used
|
|
972
|
+
// var FUNCTION = '(?!url[(])' + IDENT + '[(]';
|
|
973
|
+
var FUNCTION = '(?!url[(])(?=(' + IDENT + '))\\1[(]';
|
|
974
|
+
// ##### END: MODIFIED BY SAP
|
|
975
|
+
// INCLUDES ::= "~="
|
|
976
|
+
var INCLUDES = '~=';
|
|
977
|
+
// DASHMATCH ::= "|="
|
|
978
|
+
var DASHMATCH = '[|]=';
|
|
979
|
+
// PREFIXMATCH ::= "^="
|
|
980
|
+
var PREFIXMATCH = '[^]=';
|
|
981
|
+
// SUFFIXMATCH ::= "$="
|
|
982
|
+
var SUFFIXMATCH = '[$]=';
|
|
983
|
+
// SUBSTRINGMATCH ::= "*="
|
|
984
|
+
var SUBSTRINGMATCH = '[*]=';
|
|
985
|
+
// NewRule: one rule for all the comparison operators.
|
|
986
|
+
var CMP_OPS = '[~|^$*]=';
|
|
987
|
+
// CHAR ::= any character not matched by the above rules, except for " or '
|
|
988
|
+
// Diff: We exclude / and \ since they are handled above to prevent
|
|
989
|
+
// /* without a following */ from combining when comments are concatenated.
|
|
990
|
+
var CHAR = '[^"\'\\\\/]|/(?![/*])';
|
|
991
|
+
// BOM ::= #xFEFF
|
|
992
|
+
var BOM = '\\uFEFF';
|
|
993
|
+
|
|
994
|
+
var CSS_TOKEN = new RegExp([
|
|
995
|
+
BOM, UNICODE_RANGE, URI, FUNCTION, WORD_TERM, STRING, NUMERIC_VALUE,
|
|
996
|
+
CDO, CDC, S, COMMENT, CMP_OPS, CHAR].join("|"), 'gi');
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Decodes CSS escape sequences in a CSS string body.
|
|
1000
|
+
*/
|
|
1001
|
+
decodeCss = function (css) {
|
|
1002
|
+
return css.replace(
|
|
1003
|
+
new RegExp('\\\\(?:' + ESCAPE_TAIL + '|' + NL + ')', 'g'),
|
|
1004
|
+
decodeCssEscape);
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Given CSS Text, returns an array of normalized tokens.
|
|
1009
|
+
* @param {string} cssText
|
|
1010
|
+
* @return {Array.<string>} tokens where all ignorable token sequences have
|
|
1011
|
+
* been reduced to a single {@code " "} and all strings and
|
|
1012
|
+
* {@code url(...)} tokens have been normalized to use double quotes as
|
|
1013
|
+
* delimiters and to not otherwise contain double quotes.
|
|
1014
|
+
*/
|
|
1015
|
+
lexCss = function (cssText) {
|
|
1016
|
+
cssText = '' + cssText;
|
|
1017
|
+
var tokens = cssText.replace(/\r\n?/g, '\n') // Normalize CRLF & CR to LF.
|
|
1018
|
+
.match(CSS_TOKEN) || [];
|
|
1019
|
+
var j = 0;
|
|
1020
|
+
var last = ' ';
|
|
1021
|
+
for (var i = 0, n = tokens.length; i < n; ++i) {
|
|
1022
|
+
// Normalize all escape sequences. We will have to re-escape some
|
|
1023
|
+
// codepoints in string and url(...) bodies but we already know the
|
|
1024
|
+
// boundaries.
|
|
1025
|
+
// We might mistakenly treat a malformed identifier like \22\20\22 as a
|
|
1026
|
+
// string, but that will not break any valid stylesheets since we requote
|
|
1027
|
+
// and re-escape in string below.
|
|
1028
|
+
var tok = decodeCss(tokens[i]);
|
|
1029
|
+
var len = tok.length;
|
|
1030
|
+
var cc = tok.charCodeAt(0);
|
|
1031
|
+
tok =
|
|
1032
|
+
// All strings should be double quoted, and the body should never
|
|
1033
|
+
// contain a double quote.
|
|
1034
|
+
(cc == '"'.charCodeAt(0) || cc == '\''.charCodeAt(0))
|
|
1035
|
+
? escapeCssString(tok.substring(1, len - 1), escapeCssStrChar)
|
|
1036
|
+
// A breaking ignorable token should is replaced with a single space.
|
|
1037
|
+
: (cc == '/'.charCodeAt(0) && len > 1 // Comment.
|
|
1038
|
+
|| tok == '\\' || tok == CDC || tok == CDO || tok == '\ufeff'
|
|
1039
|
+
// Characters in W.
|
|
1040
|
+
|| cc <= ' '.charCodeAt(0))
|
|
1041
|
+
? ' '
|
|
1042
|
+
// Make sure that all url(...)s are double quoted.
|
|
1043
|
+
: /url\(/i.test(tok)
|
|
1044
|
+
? 'url(' + escapeCssString(
|
|
1045
|
+
tok.replace(
|
|
1046
|
+
new RegExp('^url\\(' + W + '["\']?|["\']?' + W + '\\)$', 'gi'),
|
|
1047
|
+
''),
|
|
1048
|
+
escapeCssUrlChar)
|
|
1049
|
+
+ ')'
|
|
1050
|
+
// Escapes in identifier like tokens will have been normalized above.
|
|
1051
|
+
: tok;
|
|
1052
|
+
// Merge adjacent space tokens.
|
|
1053
|
+
if (last != tok || tok != ' ') {
|
|
1054
|
+
tokens[j++] = last = tok;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
tokens.length = j;
|
|
1058
|
+
return tokens;
|
|
1059
|
+
};
|
|
1060
|
+
})();
|
|
1061
|
+
|
|
1062
|
+
// Exports for closure compiler.
|
|
1063
|
+
if (typeof window !== 'undefined') {
|
|
1064
|
+
window['lexCss'] = lexCss;
|
|
1065
|
+
window['decodeCss'] = decodeCss;
|
|
1066
|
+
}
|
|
1067
|
+
// Copyright (C) 2011 Google Inc.
|
|
1068
|
+
//
|
|
1069
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
1070
|
+
// you may not use this file except in compliance with the License.
|
|
1071
|
+
// You may obtain a copy of the License at
|
|
1072
|
+
//
|
|
1073
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
1074
|
+
//
|
|
1075
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
1076
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
1077
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1078
|
+
// See the License for the specific language governing permissions and
|
|
1079
|
+
// limitations under the License.
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* @fileoverview
|
|
1083
|
+
* JavaScript support for client-side CSS sanitization.
|
|
1084
|
+
* The CSS property schema API is defined in CssPropertyPatterns.java which
|
|
1085
|
+
* is used to generate css-defs.js.
|
|
1086
|
+
*
|
|
1087
|
+
* @author mikesamuel@gmail.com
|
|
1088
|
+
* \@requires CSS_PROP_BIT_ALLOWED_IN_LINK
|
|
1089
|
+
* \@requires CSS_PROP_BIT_HASH_VALUE
|
|
1090
|
+
* \@requires CSS_PROP_BIT_NEGATIVE_QUANTITY
|
|
1091
|
+
* \@requires CSS_PROP_BIT_QSTRING_CONTENT
|
|
1092
|
+
* \@requires CSS_PROP_BIT_QSTRING_URL
|
|
1093
|
+
* \@requires CSS_PROP_BIT_QUANTITY
|
|
1094
|
+
* \@requires CSS_PROP_BIT_Z_INDEX
|
|
1095
|
+
* \@requires cssSchema
|
|
1096
|
+
* \@requires decodeCss
|
|
1097
|
+
* \@requires html4
|
|
1098
|
+
* \@overrides window
|
|
1099
|
+
* \@requires parseCssStylesheet
|
|
1100
|
+
* \@provides sanitizeCssProperty
|
|
1101
|
+
* \@provides sanitizeCssSelectors
|
|
1102
|
+
* \@provides sanitizeStylesheet
|
|
1103
|
+
*/
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Given a series of normalized CSS tokens, applies a property schema, as
|
|
1107
|
+
* defined in CssPropertyPatterns.java, and sanitizes the tokens in place.
|
|
1108
|
+
* @param property a property name.
|
|
1109
|
+
* @param propertySchema a property of cssSchema as defined by
|
|
1110
|
+
* CssPropertyPatterns.java
|
|
1111
|
+
* @param tokens as parsed by lexCss. Modified in place.
|
|
1112
|
+
* @param opt_naiveUriRewriter a URI rewriter; an object with a "rewrite"
|
|
1113
|
+
* function that takes a URL and returns a safe URL.
|
|
1114
|
+
*/
|
|
1115
|
+
var sanitizeCssProperty = (function () {
|
|
1116
|
+
var NOEFFECT_URL = 'url("about:blank")';
|
|
1117
|
+
/**
|
|
1118
|
+
* The set of characters that need to be normalized inside url("...").
|
|
1119
|
+
* We normalize newlines because they are not allowed inside quoted strings,
|
|
1120
|
+
* normalize quote characters, angle-brackets, and asterisks because they
|
|
1121
|
+
* could be used to break out of the URL or introduce targets for CSS
|
|
1122
|
+
* error recovery. We normalize parentheses since they delimit unquoted
|
|
1123
|
+
* URLs and calls and could be a target for error recovery.
|
|
1124
|
+
*/
|
|
1125
|
+
var NORM_URL_REGEXP = /[\n\f\r\"\'()*<>]/g;
|
|
1126
|
+
/** The replacements for NORM_URL_REGEXP. */
|
|
1127
|
+
var NORM_URL_REPLACEMENTS = {
|
|
1128
|
+
'\n': '%0a',
|
|
1129
|
+
'\f': '%0c',
|
|
1130
|
+
'\r': '%0d',
|
|
1131
|
+
'"': '%22',
|
|
1132
|
+
'\'': '%27',
|
|
1133
|
+
'(': '%28',
|
|
1134
|
+
')': '%29',
|
|
1135
|
+
'*': '%2a',
|
|
1136
|
+
'<': '%3c',
|
|
1137
|
+
'>': '%3e'
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
function normalizeUrl(s) {
|
|
1142
|
+
if ('string' === typeof s) {
|
|
1143
|
+
return 'url("' + s.replace(NORM_URL_REGEXP, normalizeUrlChar) + '")';
|
|
1144
|
+
} else {
|
|
1145
|
+
return NOEFFECT_URL;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
function normalizeUrlChar(ch) {
|
|
1149
|
+
return NORM_URL_REPLACEMENTS[ch];
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// From RFC3986
|
|
1153
|
+
var URI_SCHEME_RE = new RegExp(
|
|
1154
|
+
'^' +
|
|
1155
|
+
'(?:' +
|
|
1156
|
+
'([^:\/?# ]+)' + // scheme
|
|
1157
|
+
':)?'
|
|
1158
|
+
);
|
|
1159
|
+
|
|
1160
|
+
var ALLOWED_URI_SCHEMES = /^(?:https?|mailto)$/i;
|
|
1161
|
+
|
|
1162
|
+
function safeUri(uri, prop, naiveUriRewriter) {
|
|
1163
|
+
if (!naiveUriRewriter) { return null; }
|
|
1164
|
+
var parsed = ('' + uri).match(URI_SCHEME_RE);
|
|
1165
|
+
if (parsed && (!parsed[1] || ALLOWED_URI_SCHEMES.test(parsed[1]))) {
|
|
1166
|
+
return naiveUriRewriter(uri, prop);
|
|
1167
|
+
} else {
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function unionArrays(arrs) {
|
|
1173
|
+
var map = {};
|
|
1174
|
+
for (var i = arrs.length; --i >= 0;) {
|
|
1175
|
+
var arr = arrs[i];
|
|
1176
|
+
for (var j = arr.length; --j >= 0;) {
|
|
1177
|
+
map[arr[j]] = ALLOWED_LITERAL;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
return map;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Normalize tokens within a function call they can match against
|
|
1185
|
+
* cssSchema[propName].cssExtra.
|
|
1186
|
+
* @return the exclusive end in tokens of the function call.
|
|
1187
|
+
*/
|
|
1188
|
+
function normalizeFunctionCall(tokens, start) {
|
|
1189
|
+
var parenDepth = 1, end = start + 1, n = tokens.length;
|
|
1190
|
+
while (end < n && parenDepth) {
|
|
1191
|
+
// TODO: Can URLs appear in functions?
|
|
1192
|
+
var token = tokens[end++];
|
|
1193
|
+
parenDepth += (token === '(' ? 1 : token === ')' ? -1 : 0);
|
|
1194
|
+
}
|
|
1195
|
+
return end;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// Used as map value to avoid hasOwnProperty checks.
|
|
1199
|
+
var ALLOWED_LITERAL = {};
|
|
1200
|
+
|
|
1201
|
+
return function (property, propertySchema, tokens, opt_naiveUriRewriter) {
|
|
1202
|
+
var propBits = propertySchema.cssPropBits;
|
|
1203
|
+
// Used to determine whether to treat quoted strings as URLs or
|
|
1204
|
+
// plain text content, and whether unrecognized keywords can be quoted
|
|
1205
|
+
// to treate ['Arial', 'Black'] equivalently to ['"Arial Black"'].
|
|
1206
|
+
var qstringBits = propBits & (
|
|
1207
|
+
CSS_PROP_BIT_QSTRING_CONTENT | CSS_PROP_BIT_QSTRING_URL);
|
|
1208
|
+
// TODO(mikesamuel): Figure out what to do with props like
|
|
1209
|
+
// content that admit both URLs and strings.
|
|
1210
|
+
|
|
1211
|
+
// Used to join unquoted keywords into a single quoted string.
|
|
1212
|
+
var lastQuoted = NaN;
|
|
1213
|
+
var i = 0, k = 0;
|
|
1214
|
+
for (;i < tokens.length; ++i) {
|
|
1215
|
+
// Has the effect of normalizing hex digits, keywords,
|
|
1216
|
+
// and function names.
|
|
1217
|
+
var token = tokens[i].toLowerCase();
|
|
1218
|
+
var cc = token.charCodeAt(0), cc1, cc2, isnum1, isnum2, end;
|
|
1219
|
+
var litGroup, litMap;
|
|
1220
|
+
token = (
|
|
1221
|
+
// Strip out spaces. Normally cssparser.js dumps these, but we
|
|
1222
|
+
// strip them out in case the content doesn't come via cssparser.js.
|
|
1223
|
+
(cc === ' '.charCodeAt(0))
|
|
1224
|
+
? ''
|
|
1225
|
+
: (cc === '"'.charCodeAt(0))
|
|
1226
|
+
? ( // Quoted string.
|
|
1227
|
+
(qstringBits === CSS_PROP_BIT_QSTRING_URL && opt_naiveUriRewriter)
|
|
1228
|
+
// Sanitize and convert to url("...") syntax.
|
|
1229
|
+
// Treat url content as case-sensitive.
|
|
1230
|
+
? (normalizeUrl(
|
|
1231
|
+
safeUri(
|
|
1232
|
+
decodeCss(tokens[i].substring(1, token.length - 1)),
|
|
1233
|
+
property,
|
|
1234
|
+
opt_naiveUriRewriter
|
|
1235
|
+
)
|
|
1236
|
+
))
|
|
1237
|
+
// Drop if plain text content strings not allowed.
|
|
1238
|
+
: (qstringBits === CSS_PROP_BIT_QSTRING_CONTENT) ? token : '')
|
|
1239
|
+
// Preserve hash color literals if allowed.
|
|
1240
|
+
: (cc === '#'.charCodeAt(0) && /^#(?:[0-9a-f]{3}){1,2}$/.test(token))
|
|
1241
|
+
? (propBits & CSS_PROP_BIT_HASH_VALUE ? token : '')
|
|
1242
|
+
// ##### BEGIN: MODIFIED BY SAP
|
|
1243
|
+
// : ('0'.charCodeAt(0) <= cc && cc <= '9'.charCodeAt(0))
|
|
1244
|
+
: ('0'.charCodeAt(0) <= cc && cc <= '9'.charCodeAt(0) && !propertySchema.cssLitNumeric)
|
|
1245
|
+
// ##### END: MODIFIED BY SAP
|
|
1246
|
+
// A number starting with a digit.
|
|
1247
|
+
? ((propBits & CSS_PROP_BIT_QUANTITY)
|
|
1248
|
+
? ((propBits & CSS_PROP_BIT_Z_INDEX)
|
|
1249
|
+
? (token.match(/^\d{1,7}$/) ? token : '')
|
|
1250
|
+
: token)
|
|
1251
|
+
: '')
|
|
1252
|
+
// Normalize quantities so they don't start with a '.' or '+' sign and
|
|
1253
|
+
// make sure they all have an integer component so can't be confused
|
|
1254
|
+
// with a dotted identifier.
|
|
1255
|
+
// This can't be done in the lexer since ".4" is a valid rule part.
|
|
1256
|
+
: (cc1 = token.charCodeAt(1),
|
|
1257
|
+
cc2 = token.charCodeAt(2),
|
|
1258
|
+
isnum1 = '0'.charCodeAt(0) <= cc1 && cc1 <= '9'.charCodeAt(0),
|
|
1259
|
+
isnum2 = '0'.charCodeAt(0) <= cc2 && cc2 <= '9'.charCodeAt(0),
|
|
1260
|
+
// +.5 -> 0.5 if allowed.
|
|
1261
|
+
(cc === '+'.charCodeAt(0)
|
|
1262
|
+
&& (isnum1 || (cc1 === '.'.charCodeAt(0) && isnum2))))
|
|
1263
|
+
? ((propBits & CSS_PROP_BIT_QUANTITY)
|
|
1264
|
+
? ((propBits & CSS_PROP_BIT_Z_INDEX)
|
|
1265
|
+
? (token.match(/^\+\d{1,7}$/) ? token : '')
|
|
1266
|
+
: ((isnum1 ? '' : '0') + token.substring(1)))
|
|
1267
|
+
: '')
|
|
1268
|
+
// -.5 -> -0.5 if allowed otherwise -> 0 if quantities allowed.
|
|
1269
|
+
: (cc === '-'.charCodeAt(0)
|
|
1270
|
+
&& (isnum1 || (cc1 === '.'.charCodeAt(0) && isnum2)))
|
|
1271
|
+
? ((propBits & CSS_PROP_BIT_NEGATIVE_QUANTITY)
|
|
1272
|
+
? ((propBits & CSS_PROP_BIT_Z_INDEX)
|
|
1273
|
+
? (token.match(/^\-\d{1,7}$/) ? token : '')
|
|
1274
|
+
: ((isnum1 ? '-' : '-0') + token.substring(1)))
|
|
1275
|
+
: ((propBits & CSS_PROP_BIT_QUANTITY) ? '0' : ''))
|
|
1276
|
+
// .5 -> 0.5 if allowed.
|
|
1277
|
+
: (cc === '.'.charCodeAt(0) && isnum1)
|
|
1278
|
+
? ((propBits & CSS_PROP_BIT_QUANTITY) ? '0' + token : '')
|
|
1279
|
+
// Handle url("...") by rewriting the body.
|
|
1280
|
+
: ('url(' === token.substring(0, 4))
|
|
1281
|
+
? ((opt_naiveUriRewriter && (qstringBits & CSS_PROP_BIT_QSTRING_URL))
|
|
1282
|
+
? normalizeUrl(
|
|
1283
|
+
safeUri(
|
|
1284
|
+
tokens[i].substring(5, token.length - 2),
|
|
1285
|
+
property,
|
|
1286
|
+
opt_naiveUriRewriter
|
|
1287
|
+
)
|
|
1288
|
+
)
|
|
1289
|
+
: '')
|
|
1290
|
+
// Handle func(...) and literal tokens
|
|
1291
|
+
// such as keywords and punctuation.
|
|
1292
|
+
: (
|
|
1293
|
+
// Step 1. Combine func(...) into something that can be compared
|
|
1294
|
+
// against propertySchema.cssExtra.
|
|
1295
|
+
(token.charAt(token.length-1) === '(')
|
|
1296
|
+
&& (end = normalizeFunctionCall(tokens, i),
|
|
1297
|
+
// When tokens is
|
|
1298
|
+
// ['x', ' ', 'rgb(', '255', ',', '0', ',', '0', ')', ' ', 'y']
|
|
1299
|
+
// and i is the index of 'rgb(' and end is the index of ')'
|
|
1300
|
+
// splices tokens to where i now is the index of the whole call:
|
|
1301
|
+
// ['x', ' ', 'rgb( 255 , 0 , 0 )', ' ', 'y']
|
|
1302
|
+
tokens.splice(i, end - i,
|
|
1303
|
+
token = tokens.slice(i, end).join(' '))),
|
|
1304
|
+
litGroup = propertySchema.cssLitGroup,
|
|
1305
|
+
litMap = (
|
|
1306
|
+
litGroup
|
|
1307
|
+
? (propertySchema.cssLitMap
|
|
1308
|
+
// Lazily compute the union from litGroup.
|
|
1309
|
+
|| (propertySchema.cssLitMap = unionArrays(litGroup)))
|
|
1310
|
+
: ALLOWED_LITERAL), // A convenient empty object.
|
|
1311
|
+
(litMap[token] === ALLOWED_LITERAL
|
|
1312
|
+
|| propertySchema.cssExtra && propertySchema.cssExtra.test(token)))
|
|
1313
|
+
// Token is in the literal map or matches extra.
|
|
1314
|
+
? token
|
|
1315
|
+
: (/^\w+$/.test(token)
|
|
1316
|
+
&& (qstringBits === CSS_PROP_BIT_QSTRING_CONTENT))
|
|
1317
|
+
// Quote unrecognized keywords so font names like
|
|
1318
|
+
// Arial Bold
|
|
1319
|
+
// ->
|
|
1320
|
+
// "Arial Bold"
|
|
1321
|
+
? (lastQuoted+1 === k
|
|
1322
|
+
// If the last token was also a keyword that was quoted, then
|
|
1323
|
+
// combine this token into that.
|
|
1324
|
+
? (tokens[lastQuoted] = tokens[lastQuoted]
|
|
1325
|
+
.substring(0, tokens[lastQuoted].length-1) + ' ' + token + '"',
|
|
1326
|
+
token = '')
|
|
1327
|
+
: (lastQuoted = k, '"' + token + '"'))
|
|
1328
|
+
// Disallowed.
|
|
1329
|
+
: '');
|
|
1330
|
+
if (token) {
|
|
1331
|
+
tokens[k++] = token;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
// For single URL properties, if the URL failed to pass the sanitizer,
|
|
1335
|
+
// then just drop it.
|
|
1336
|
+
if (k === 1 && tokens[0] === NOEFFECT_URL) { k = 0; }
|
|
1337
|
+
tokens.length = k;
|
|
1338
|
+
};
|
|
1339
|
+
})();
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Given a series of tokens, returns two lists of sanitized selectors.
|
|
1343
|
+
* @param {Array.<string>} selectors In the form produces by csslexer.js.
|
|
1344
|
+
* @param {string} suffix a suffix that is added to all IDs and which is
|
|
1345
|
+
* used as a CLASS names so that the returned selectors will only match
|
|
1346
|
+
* nodes under one with suffix as a class name.
|
|
1347
|
+
* If suffix is {@code "sfx"}, the selector
|
|
1348
|
+
* {@code ["a", "#foo", " ", "b", ".bar"]} will be namespaced to
|
|
1349
|
+
* {@code [".sfx", " ", "a", "#foo-sfx", " ", "b", ".bar"]}.
|
|
1350
|
+
* @return {Array.<Array.<string>>} an array of length 2 where the zeroeth
|
|
1351
|
+
* element contains history-insensitive selectors and the first element
|
|
1352
|
+
* contains history-sensitive selectors.
|
|
1353
|
+
*/
|
|
1354
|
+
function sanitizeCssSelectors(selectors, suffix) {
|
|
1355
|
+
// Produce two distinct lists of selectors to sequester selectors that are
|
|
1356
|
+
// history sensitive (:visited), so that we can disallow properties in the
|
|
1357
|
+
// property groups for the history sensitive ones.
|
|
1358
|
+
var historySensitiveSelectors = [];
|
|
1359
|
+
var historyInsensitiveSelectors = [];
|
|
1360
|
+
|
|
1361
|
+
// Remove any spaces that are not operators.
|
|
1362
|
+
var k = 0, i;
|
|
1363
|
+
for (i = 0; i < selectors.length; ++i) {
|
|
1364
|
+
if (!(selectors[i] == ' '
|
|
1365
|
+
&& (selectors[i-1] == '>' || selectors[i+1] == '>'))) {
|
|
1366
|
+
selectors[k++] = selectors[i];
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
selectors.length = k;
|
|
1370
|
+
|
|
1371
|
+
// Split around commas. If there is an error in one of the comma separated
|
|
1372
|
+
// bits, we throw the whole away, but the failure of one selector does not
|
|
1373
|
+
// affect others.
|
|
1374
|
+
var n = selectors.length, start = 0;
|
|
1375
|
+
for (i = 0; i < n; ++i) {
|
|
1376
|
+
if (selectors[i] == ',') {
|
|
1377
|
+
processSelector(start, i);
|
|
1378
|
+
start = i+1;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
processSelector(start, n);
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
function processSelector(start, end) {
|
|
1385
|
+
var historySensitive = false;
|
|
1386
|
+
|
|
1387
|
+
// Space around commas is not an operator.
|
|
1388
|
+
if (selectors[start] === ' ') { ++start; }
|
|
1389
|
+
if (end-1 !== start && selectors[end] === ' ') { --end; }
|
|
1390
|
+
|
|
1391
|
+
// Split the selector into element selectors, content around
|
|
1392
|
+
// space (ancestor operator) and '>' (descendant operator).
|
|
1393
|
+
var out = [];
|
|
1394
|
+
var lastOperator = start;
|
|
1395
|
+
var elSelector = '';
|
|
1396
|
+
for (var i = start; i < end; ++i) {
|
|
1397
|
+
var tok = selectors[i];
|
|
1398
|
+
var isChild = (tok === '>');
|
|
1399
|
+
if (isChild || tok === ' ') {
|
|
1400
|
+
// We've found the end of a single link in the selector chain.
|
|
1401
|
+
// We disallow absolute positions relative to html.
|
|
1402
|
+
elSelector = processElementSelector(lastOperator, i, false);
|
|
1403
|
+
if (!elSelector || (isChild && /^html/i.test(elSelector))) {
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
lastOperator = i+1;
|
|
1407
|
+
out.push(elSelector, isChild ? ' > ' : ' ');
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
elSelector = processElementSelector(lastOperator, end, true);
|
|
1411
|
+
if (!elSelector) { return; }
|
|
1412
|
+
out.push(elSelector);
|
|
1413
|
+
|
|
1414
|
+
function processElementSelector(start, end, last) {
|
|
1415
|
+
var debugStart = start, debugEnd = end;
|
|
1416
|
+
|
|
1417
|
+
// Split the element selector into three parts.
|
|
1418
|
+
// DIV.foo#bar:hover
|
|
1419
|
+
// ^ ^
|
|
1420
|
+
// el classes pseudo
|
|
1421
|
+
var element, classId, pseudoSelector, tok, elType;
|
|
1422
|
+
element = '';
|
|
1423
|
+
if (start < end) {
|
|
1424
|
+
tok = selectors[start].toLowerCase();
|
|
1425
|
+
if (tok === '*'
|
|
1426
|
+
|| (tok === 'body' && start+1 !== end && !last)
|
|
1427
|
+
|| ('number' === typeof (elType = html4.ELEMENTS[tok])
|
|
1428
|
+
&& !(elType & html4.eflags.UNSAFE))) {
|
|
1429
|
+
++start;
|
|
1430
|
+
element = tok;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
classId = '';
|
|
1434
|
+
while (start < end) {
|
|
1435
|
+
tok = selectors[start];
|
|
1436
|
+
if (tok.charAt(0) === '#') {
|
|
1437
|
+
if (/^#_|__$|[^#0-9A-Za-z:_\-]/.test(tok)) { return null; }
|
|
1438
|
+
// Rewrite ID elements to include the suffix.
|
|
1439
|
+
classId += tok + '-' + suffix;
|
|
1440
|
+
} else if (tok === '.') {
|
|
1441
|
+
if (++start < end
|
|
1442
|
+
&& /^[0-9A-Za-z:_\-]+$/.test(tok = selectors[start])
|
|
1443
|
+
&& !/^_|__$/.test(tok)) {
|
|
1444
|
+
classId += '.' + tok;
|
|
1445
|
+
} else {
|
|
1446
|
+
return null;
|
|
1447
|
+
}
|
|
1448
|
+
} else {
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
++start;
|
|
1452
|
+
}
|
|
1453
|
+
pseudoSelector = '';
|
|
1454
|
+
if (start < end && selectors[start] === ':') {
|
|
1455
|
+
tok = selectors[++start];
|
|
1456
|
+
if (tok === 'visited' || tok === 'link') {
|
|
1457
|
+
if (!/^[a*]?$/.test(element)) {
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
historySensitive = true;
|
|
1461
|
+
pseudoSelector = ':' + tok;
|
|
1462
|
+
element = 'a';
|
|
1463
|
+
++start;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
if (start === end) {
|
|
1467
|
+
return element + classId + pseudoSelector;
|
|
1468
|
+
}
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
var safeSelector = out.join('');
|
|
1474
|
+
if (/^body\b/.test(safeSelector)) {
|
|
1475
|
+
// Substitute the class that is attached to pseudo body elements for
|
|
1476
|
+
// the body element.
|
|
1477
|
+
safeSelector = '.vdoc-body___.' + suffix + safeSelector.substring(4);
|
|
1478
|
+
} else {
|
|
1479
|
+
// Namespace the selector so that it only matches under
|
|
1480
|
+
// a node with suffix in its CLASS attribute.
|
|
1481
|
+
safeSelector = '.' + suffix + ' ' + safeSelector;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
(historySensitive
|
|
1485
|
+
? historySensitiveSelectors
|
|
1486
|
+
: historyInsensitiveSelectors).push(safeSelector);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
return [historyInsensitiveSelectors, historySensitiveSelectors];
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
var sanitizeStylesheet = (function () {
|
|
1493
|
+
var allowed = {};
|
|
1494
|
+
var cssMediaTypeWhitelist = {
|
|
1495
|
+
'braille': allowed,
|
|
1496
|
+
'embossed': allowed,
|
|
1497
|
+
'handheld': allowed,
|
|
1498
|
+
'print': allowed,
|
|
1499
|
+
'projection': allowed,
|
|
1500
|
+
'screen': allowed,
|
|
1501
|
+
'speech': allowed,
|
|
1502
|
+
'tty': allowed,
|
|
1503
|
+
'tv': allowed
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Given a series of sanitized tokens, removes any properties that would
|
|
1508
|
+
* leak user history if allowed to style links differently depending on
|
|
1509
|
+
* whether the linked URL is in the user's browser history.
|
|
1510
|
+
* @param {Array.<string>} blockOfProperties
|
|
1511
|
+
*/
|
|
1512
|
+
function sanitizeHistorySensitive(blockOfProperties) {
|
|
1513
|
+
var elide = false;
|
|
1514
|
+
for (var i = 0, n = blockOfProperties.length; i < n-1; ++i) {
|
|
1515
|
+
var token = blockOfProperties[i];
|
|
1516
|
+
if (':' === blockOfProperties[i+1]) {
|
|
1517
|
+
elide = !(cssSchema[token].cssPropBits & CSS_PROP_BIT_ALLOWED_IN_LINK);
|
|
1518
|
+
}
|
|
1519
|
+
if (elide) { blockOfProperties[i] = ''; }
|
|
1520
|
+
if (';' === token) { elide = false; }
|
|
1521
|
+
}
|
|
1522
|
+
return blockOfProperties.join('');
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* @param {string} cssText a string containing a CSS stylesheet.
|
|
1527
|
+
* @param {string} suffix a suffix that is added to all IDs and which is
|
|
1528
|
+
* used as a CLASS names so that the returned selectors will only match
|
|
1529
|
+
* nodes under one with suffix as a class name.
|
|
1530
|
+
* If suffix is {@code "sfx"}, the selector
|
|
1531
|
+
* {@code ["a", "#foo", " ", "b", ".bar"]} will be namespaced to
|
|
1532
|
+
* {@code [".sfx", " ", "a", "#foo-sfx", " ", "b", ".bar"]}.
|
|
1533
|
+
* @param {function(string, string)} opt_naiveUriRewriter maps URLs of media
|
|
1534
|
+
* (images, sounds) that appear as CSS property values to sanitized
|
|
1535
|
+
* URLs or null if the URL should not be allowed as an external media
|
|
1536
|
+
* file in sanitized CSS.
|
|
1537
|
+
*/
|
|
1538
|
+
return function /*sanitizeStylesheet*/(
|
|
1539
|
+
cssText, suffix, opt_naiveUriRewriter) {
|
|
1540
|
+
var safeCss = void 0;
|
|
1541
|
+
// A stack describing the { ... } regions.
|
|
1542
|
+
// Null elements indicate blocks that should not be emitted.
|
|
1543
|
+
var blockStack = [];
|
|
1544
|
+
// True when the content of the current block should be left off safeCss.
|
|
1545
|
+
var elide = false;
|
|
1546
|
+
parseCssStylesheet(
|
|
1547
|
+
cssText,
|
|
1548
|
+
{
|
|
1549
|
+
startStylesheet: function () {
|
|
1550
|
+
safeCss = [];
|
|
1551
|
+
},
|
|
1552
|
+
endStylesheet: function () {
|
|
1553
|
+
},
|
|
1554
|
+
startAtrule: function (atIdent, headerArray) {
|
|
1555
|
+
if (elide) {
|
|
1556
|
+
atIdent = null;
|
|
1557
|
+
} else if (atIdent === '@media') {
|
|
1558
|
+
headerArray = headerArray.filter(
|
|
1559
|
+
function (mediaType) {
|
|
1560
|
+
return cssMediaTypeWhitelist[mediaType] == allowed;
|
|
1561
|
+
});
|
|
1562
|
+
if (headerArray.length) {
|
|
1563
|
+
safeCss.push(atIdent, headerArray.join(','), '{');
|
|
1564
|
+
} else {
|
|
1565
|
+
atIdent = null;
|
|
1566
|
+
}
|
|
1567
|
+
} else {
|
|
1568
|
+
if (atIdent === '@import') {
|
|
1569
|
+
// TODO: Use a logger instead.
|
|
1570
|
+
if (window.console) {
|
|
1571
|
+
window.console.log(
|
|
1572
|
+
'@import ' + headerArray.join(' ') + ' elided');
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
atIdent = null; // Elide the block.
|
|
1576
|
+
}
|
|
1577
|
+
elide = !atIdent;
|
|
1578
|
+
blockStack.push(atIdent);
|
|
1579
|
+
},
|
|
1580
|
+
endAtrule: function () {
|
|
1581
|
+
var atIdent = blockStack.pop();
|
|
1582
|
+
if (!elide) {
|
|
1583
|
+
safeCss.push(';');
|
|
1584
|
+
}
|
|
1585
|
+
checkElide();
|
|
1586
|
+
},
|
|
1587
|
+
startBlock: function () {
|
|
1588
|
+
// There are no bare blocks in CSS, so we do not change the
|
|
1589
|
+
// block stack here, but instead in the events that bracket
|
|
1590
|
+
// blocks.
|
|
1591
|
+
if (!elide) {
|
|
1592
|
+
safeCss.push('{');
|
|
1593
|
+
}
|
|
1594
|
+
},
|
|
1595
|
+
endBlock: function () {
|
|
1596
|
+
if (!elide) {
|
|
1597
|
+
safeCss.push('}');
|
|
1598
|
+
elide = true; // skip any semicolon from endAtRule.
|
|
1599
|
+
}
|
|
1600
|
+
},
|
|
1601
|
+
startRuleset: function (selectorArray) {
|
|
1602
|
+
var historySensitiveSelectors = void 0;
|
|
1603
|
+
var removeHistoryInsensitiveSelectors = false;
|
|
1604
|
+
if (!elide) {
|
|
1605
|
+
var selectors = sanitizeCssSelectors(selectorArray, suffix);
|
|
1606
|
+
var historyInsensitiveSelectors = selectors[0];
|
|
1607
|
+
historySensitiveSelectors = selectors[1];
|
|
1608
|
+
if (!historyInsensitiveSelectors.length
|
|
1609
|
+
&& !historySensitiveSelectors.length) {
|
|
1610
|
+
elide = true;
|
|
1611
|
+
} else {
|
|
1612
|
+
var selector = historyInsensitiveSelectors.join(', ');
|
|
1613
|
+
if (!selector) {
|
|
1614
|
+
// If we have only history sensitive selectors,
|
|
1615
|
+
// use an impossible rule so that we can capture the content
|
|
1616
|
+
// for later processing by
|
|
1617
|
+
// history insenstive content for use below.
|
|
1618
|
+
selector = 'head > html';
|
|
1619
|
+
removeHistoryInsensitiveSelectors = true;
|
|
1620
|
+
}
|
|
1621
|
+
safeCss.push(selector, '{');
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
blockStack.push(
|
|
1625
|
+
elide
|
|
1626
|
+
? null
|
|
1627
|
+
// Sometimes a single list of selectors is split in two,
|
|
1628
|
+
// div, a:visited
|
|
1629
|
+
// because we want to allow some properties for DIV that
|
|
1630
|
+
// we don't want to allow for A:VISITED to avoid leaking
|
|
1631
|
+
// user history.
|
|
1632
|
+
// Store the history sensitive selectors and the position
|
|
1633
|
+
// where the block starts so we can later create a copy
|
|
1634
|
+
// of the permissive tokens, and filter it to handle the
|
|
1635
|
+
// history sensitive case.
|
|
1636
|
+
: {
|
|
1637
|
+
historySensitiveSelectors: historySensitiveSelectors,
|
|
1638
|
+
endOfSelectors: safeCss.length - 1, // 1 is open curly
|
|
1639
|
+
removeHistoryInsensitiveSelectors:
|
|
1640
|
+
removeHistoryInsensitiveSelectors
|
|
1641
|
+
});
|
|
1642
|
+
},
|
|
1643
|
+
endRuleset: function () {
|
|
1644
|
+
var rules = blockStack.pop();
|
|
1645
|
+
var propertiesEnd = safeCss.length;
|
|
1646
|
+
if (!elide) {
|
|
1647
|
+
safeCss.push('}');
|
|
1648
|
+
if (rules) {
|
|
1649
|
+
var extraSelectors = rules.historySensitiveSelectors;
|
|
1650
|
+
if (extraSelectors.length) {
|
|
1651
|
+
var propertyGroupTokens = safeCss.slice(rules.endOfSelectors);
|
|
1652
|
+
safeCss.push(extraSelectors.join(', '),
|
|
1653
|
+
sanitizeHistorySensitive(propertyGroupTokens));
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
if (rules && rules.removeHistoryInsensitiveSelectors) {
|
|
1658
|
+
safeCss.splice(
|
|
1659
|
+
// -1 and +1 account for curly braces.
|
|
1660
|
+
rules.endOfSelectors - 1, propertiesEnd + 1);
|
|
1661
|
+
}
|
|
1662
|
+
checkElide();
|
|
1663
|
+
},
|
|
1664
|
+
declaration: function (property, valueArray) {
|
|
1665
|
+
if (!elide) {
|
|
1666
|
+
var schema = cssSchema[property];
|
|
1667
|
+
if (schema) {
|
|
1668
|
+
sanitizeCssProperty(property, schema, valueArray, opt_naiveUriRewriter);
|
|
1669
|
+
if (valueArray.length) {
|
|
1670
|
+
safeCss.push(property, ':', valueArray.join(' '), ';');
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
function checkElide() {
|
|
1677
|
+
elide = blockStack.length !== 0
|
|
1678
|
+
&& blockStack[blockStack.length-1] !== null;
|
|
1679
|
+
}
|
|
1680
|
+
return safeCss.join('');
|
|
1681
|
+
};
|
|
1682
|
+
})();
|
|
1683
|
+
|
|
1684
|
+
// Exports for closure compiler.
|
|
1685
|
+
if (typeof window !== 'undefined') {
|
|
1686
|
+
window['sanitizeCssProperty'] = sanitizeCssProperty;
|
|
1687
|
+
window['sanitizeCssSelectors'] = sanitizeCssSelectors;
|
|
1688
|
+
window['sanitizeStylesheet'] = sanitizeStylesheet;
|
|
1689
|
+
}
|
|
1690
|
+
// Copyright (C) 2010 Google Inc.
|
|
1691
|
+
//
|
|
1692
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
1693
|
+
// you may not use this file except in compliance with the License.
|
|
1694
|
+
// You may obtain a copy of the License at
|
|
1695
|
+
//
|
|
1696
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
1697
|
+
//
|
|
1698
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
1699
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
1700
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1701
|
+
// See the License for the specific language governing permissions and
|
|
1702
|
+
// limitations under the License.
|
|
1703
|
+
|
|
1704
|
+
/**
|
|
1705
|
+
* @fileoverview
|
|
1706
|
+
* Utilities for dealing with CSS source code.
|
|
1707
|
+
*
|
|
1708
|
+
* @author mikesamuel@gmail.com
|
|
1709
|
+
* \@requires lexCss
|
|
1710
|
+
* \@overrides window
|
|
1711
|
+
* \@provides parseCssStylesheet, parseCssDeclarations
|
|
1712
|
+
*/
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* parseCssStylesheet takes a chunk of CSS text and a handler object with
|
|
1716
|
+
* methods that it calls as below:
|
|
1717
|
+
* <pre>
|
|
1718
|
+
* // At the beginning of a stylesheet.
|
|
1719
|
+
* handler.startStylesheet();
|
|
1720
|
+
*
|
|
1721
|
+
* // For an @foo rule ended by a semicolon: @import "foo.css";
|
|
1722
|
+
* handler.startAtrule('@import', ['"foo.css"']);
|
|
1723
|
+
* handler.endAtrule();
|
|
1724
|
+
*
|
|
1725
|
+
* // For an @foo rule ended with a block. @media print { ... }
|
|
1726
|
+
* handler.startAtrule('@media', ['print']);
|
|
1727
|
+
* handler.startBlock();
|
|
1728
|
+
* // Calls to contents elided. Probably selectors and declarations as below.
|
|
1729
|
+
* handler.endBlock();
|
|
1730
|
+
* handler.endAtrule();
|
|
1731
|
+
*
|
|
1732
|
+
* // For a ruleset: p.clazz q, s { color: blue; }
|
|
1733
|
+
* handler.startRuleset(['p', '.', 'clazz', ' ', 'q', ',', ' ', 's']);
|
|
1734
|
+
* handler.declaration('color', ['blue']);
|
|
1735
|
+
* handler.endRuleset();
|
|
1736
|
+
*
|
|
1737
|
+
* // At the end of a stylesheet.
|
|
1738
|
+
* handler.endStylesheet();
|
|
1739
|
+
* </pre>
|
|
1740
|
+
* When errors are encountered, the parser drops the useless tokens and
|
|
1741
|
+
* attempts to resume parsing.
|
|
1742
|
+
*
|
|
1743
|
+
* @param {string} cssText CSS3 content to parse as a stylesheet.
|
|
1744
|
+
* @param {Object} handler An object like <pre>{
|
|
1745
|
+
* startStylesheet: function () { ... },
|
|
1746
|
+
* endStylesheet: function () { ... },
|
|
1747
|
+
* startAtrule: function (atIdent, headerArray) { ... },
|
|
1748
|
+
* endAtrule: function () { ... },
|
|
1749
|
+
* startBlock: function () { ... },
|
|
1750
|
+
* endBlock: function () { ... },
|
|
1751
|
+
* startRuleset: function (selectorArray) { ... },
|
|
1752
|
+
* endRuleset: function () { ... },
|
|
1753
|
+
* declaration: function (property, valueArray) { ... },
|
|
1754
|
+
* }</pre>
|
|
1755
|
+
*/
|
|
1756
|
+
var parseCssStylesheet;
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* parseCssDeclarations parses a run of declaration productions as seen in the
|
|
1760
|
+
* body of the HTML5 {@code style} attribute.
|
|
1761
|
+
*
|
|
1762
|
+
* @param {string} cssText CSS3 content to parse as a run of declarations.
|
|
1763
|
+
* @param {Object} handler An object like <pre>{
|
|
1764
|
+
* declaration: function (property, valueArray) { ... },
|
|
1765
|
+
* }</pre>
|
|
1766
|
+
*/
|
|
1767
|
+
var parseCssDeclarations;
|
|
1768
|
+
|
|
1769
|
+
(function () {
|
|
1770
|
+
// stylesheet : [ CDO | CDC | S | statement ]*;
|
|
1771
|
+
parseCssStylesheet = function(cssText, handler) {
|
|
1772
|
+
var toks = lexCss(cssText);
|
|
1773
|
+
if (handler.startStylesheet) { handler.startStylesheet(); }
|
|
1774
|
+
for (var i = 0, n = toks.length; i < n;) {
|
|
1775
|
+
// CDO and CDC ("<!--" and "-->") are converted to space by the lexer.
|
|
1776
|
+
i = toks[i] === ' ' ? i+1 : statement(toks, i, n, handler);
|
|
1777
|
+
}
|
|
1778
|
+
if (handler.endStylesheet) { handler.endStylesheet(); }
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
// statement : ruleset | at-rule;
|
|
1782
|
+
function statement(toks, i, n, handler) {
|
|
1783
|
+
if (i < n) {
|
|
1784
|
+
var tok = toks[i];
|
|
1785
|
+
if (tok.charAt(0) === '@') {
|
|
1786
|
+
return atrule(toks, i, n, handler, true);
|
|
1787
|
+
} else {
|
|
1788
|
+
return ruleset(toks, i, n, handler);
|
|
1789
|
+
}
|
|
1790
|
+
} else {
|
|
1791
|
+
return i;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
// at-rule : ATKEYWORD S* any* [ block | ';' S* ];
|
|
1796
|
+
function atrule(toks, i, n, handler, blockok) {
|
|
1797
|
+
var start = i++;
|
|
1798
|
+
while (i < n && toks[i] !== '{' && toks[i] !== ';') {
|
|
1799
|
+
++i;
|
|
1800
|
+
}
|
|
1801
|
+
if (i < n && (blockok || toks[i] === ';')) {
|
|
1802
|
+
var s = start+1, e = i;
|
|
1803
|
+
if (s < n && toks[s] === ' ') { ++s; }
|
|
1804
|
+
if (e > s && toks[e-1] === ' ') { --e; }
|
|
1805
|
+
if (handler.startAtrule) {
|
|
1806
|
+
handler.startAtrule(toks[start].toLowerCase(), toks.slice(s, e));
|
|
1807
|
+
}
|
|
1808
|
+
i = (toks[i] === '{')
|
|
1809
|
+
? block(toks, i, n, handler)
|
|
1810
|
+
: i+1; // Skip over ';'
|
|
1811
|
+
if (handler.endAtrule) {
|
|
1812
|
+
handler.endAtrule();
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
// Else we reached end of input or are missing a semicolon.
|
|
1816
|
+
// Drop the rule on the floor.
|
|
1817
|
+
return i;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
// block : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*;
|
|
1821
|
+
// Assumes the leading '{' has been verified by callers.
|
|
1822
|
+
function block(toks, i, n, handler) {
|
|
1823
|
+
++i; // skip over '{'
|
|
1824
|
+
if (handler.startBlock) { handler.startBlock(); }
|
|
1825
|
+
while (i < n) {
|
|
1826
|
+
var ch = toks[i].charAt(0);
|
|
1827
|
+
if (ch == '}') {
|
|
1828
|
+
++i;
|
|
1829
|
+
break;
|
|
1830
|
+
}
|
|
1831
|
+
if (ch === ' ' || ch === ';') {
|
|
1832
|
+
i = i+1;
|
|
1833
|
+
} else if (ch === '@') {
|
|
1834
|
+
i = atrule(toks, i, n, handler, false);
|
|
1835
|
+
} else if (ch === '{') {
|
|
1836
|
+
i = block(toks, i, n, handler);
|
|
1837
|
+
} else {
|
|
1838
|
+
// Instead of using (any* block) to subsume ruleset we allow either
|
|
1839
|
+
// blocks or rulesets with a non-blank selector.
|
|
1840
|
+
// This is more restrictive but does not require atrule specific
|
|
1841
|
+
// parse tree fixup to realize that the contents of the block in
|
|
1842
|
+
// @media print { ... }
|
|
1843
|
+
// is a ruleset. We just don't care about any block carrying at-rules
|
|
1844
|
+
// whose body content is not ruleset content.
|
|
1845
|
+
i = ruleset(toks, i, n, handler);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
if (handler.endBlock) { handler.endBlock(); }
|
|
1849
|
+
return i;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
// ruleset : selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S*;
|
|
1853
|
+
function ruleset(toks, i, n, handler) {
|
|
1854
|
+
// toks[s:e] are the selector tokens including internal whitespace.
|
|
1855
|
+
var s = i, e = selector(toks, i, n, true);
|
|
1856
|
+
if (e < 0) {
|
|
1857
|
+
// Skip malformed content per selector calling convention.
|
|
1858
|
+
e = ~e;
|
|
1859
|
+
// Make sure we skip at least one token.
|
|
1860
|
+
return i === e ? e+1 : e;
|
|
1861
|
+
}
|
|
1862
|
+
i = e;
|
|
1863
|
+
// Don't include any trailing space in the selector slice.
|
|
1864
|
+
if (e > s && toks[e-1] === ' ') { --e; }
|
|
1865
|
+
var tok = toks[i];
|
|
1866
|
+
++i; // Skip over '{'
|
|
1867
|
+
if (tok !== '{') {
|
|
1868
|
+
// Skips past the '{' when there is a malformed input.
|
|
1869
|
+
return i;
|
|
1870
|
+
}
|
|
1871
|
+
if (handler.startRuleset) {
|
|
1872
|
+
handler.startRuleset(toks.slice(s, e));
|
|
1873
|
+
}
|
|
1874
|
+
while (i < n) {
|
|
1875
|
+
tok = toks[i];
|
|
1876
|
+
if (tok === '}') {
|
|
1877
|
+
++i;
|
|
1878
|
+
break;
|
|
1879
|
+
}
|
|
1880
|
+
if (tok === ' ') {
|
|
1881
|
+
i = i+1;
|
|
1882
|
+
} else {
|
|
1883
|
+
i = declaration(toks, i, n, handler);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
if (handler.endRuleset) {
|
|
1887
|
+
handler.endRuleset();
|
|
1888
|
+
}
|
|
1889
|
+
return i < n ? i+1 : i;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// selector : any+;
|
|
1893
|
+
// any : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
|
|
1894
|
+
// | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
|
|
1895
|
+
// | FUNCTION S* any* ')' | DASHMATCH | '(' S* any* ')'
|
|
1896
|
+
// | '[' S* any* ']' ] S*;
|
|
1897
|
+
// A negative return value, rv, indicates the selector was malformed and
|
|
1898
|
+
// the index at which we stopped is ~rv.
|
|
1899
|
+
function selector(toks, i, n, allowSemi) {
|
|
1900
|
+
var s = i;
|
|
1901
|
+
// The definition of any above can be summed up as
|
|
1902
|
+
// "any run of token except ('[', ']', '(', ')', ':', ';', '{', '}')
|
|
1903
|
+
// or nested runs of parenthesized tokens or square bracketed tokens".
|
|
1904
|
+
// Spaces are significant in the selector.
|
|
1905
|
+
// Selector is used as (selector?) so the below looks for (any*) for
|
|
1906
|
+
// simplicity.
|
|
1907
|
+
var tok;
|
|
1908
|
+
// Keeping a stack pointer actually causes this to minify better since
|
|
1909
|
+
// ".length" and ".push" are a lo of chars.
|
|
1910
|
+
var brackets = [], stackLast = -1;
|
|
1911
|
+
for (;i < n; ++i) {
|
|
1912
|
+
tok = toks[i].charAt(0);
|
|
1913
|
+
if (tok === '[' || tok === '(') {
|
|
1914
|
+
brackets[++stackLast] = tok;
|
|
1915
|
+
} else if ((tok === ']' && brackets[stackLast] === '[') ||
|
|
1916
|
+
(tok === ')' && brackets[stackLast] === '(')) {
|
|
1917
|
+
--stackLast;
|
|
1918
|
+
} else if (tok === '{' || tok === '}' || tok === ';' || tok === '@'
|
|
1919
|
+
|| (tok === ':' && !allowSemi)) {
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
if (stackLast >= 0) {
|
|
1924
|
+
// Returns the bitwise inverse of i+1 to indicate an error in the
|
|
1925
|
+
// token stream so that clients can ignore it.
|
|
1926
|
+
i = ~(i+1);
|
|
1927
|
+
}
|
|
1928
|
+
return i;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
var ident = /^-?[a-z]/i;
|
|
1932
|
+
|
|
1933
|
+
// declaration : property ':' S* value;
|
|
1934
|
+
// property : IDENT S*;
|
|
1935
|
+
// value : [ any | block | ATKEYWORD S* ]+;
|
|
1936
|
+
function declaration(toks, i, n, handler) {
|
|
1937
|
+
var property = toks[i++];
|
|
1938
|
+
if (!ident.test(property)) {
|
|
1939
|
+
return i+1; // skip one token.
|
|
1940
|
+
}
|
|
1941
|
+
var tok;
|
|
1942
|
+
if (i < n && toks[i] === ' ') { ++i; }
|
|
1943
|
+
if (i == n || toks[i] !== ':') {
|
|
1944
|
+
// skip tokens to next semi or close bracket.
|
|
1945
|
+
while (i < n && (tok = toks[i]) !== ';' && tok !== '}') { ++i; }
|
|
1946
|
+
return i;
|
|
1947
|
+
}
|
|
1948
|
+
++i;
|
|
1949
|
+
if (i < n && toks[i] === ' ') { ++i; }
|
|
1950
|
+
|
|
1951
|
+
// None of the rules we care about want atrules or blocks in value, so
|
|
1952
|
+
// we look for any+ but that is the same as selector but not zero-length.
|
|
1953
|
+
// This gets us the benefit of not emitting any value with mismatched
|
|
1954
|
+
// brackets.
|
|
1955
|
+
var s = i, e = selector(toks, i, n, false);
|
|
1956
|
+
if (e < 0) {
|
|
1957
|
+
// Skip malformed content per selector calling convention.
|
|
1958
|
+
e = ~e;
|
|
1959
|
+
} else {
|
|
1960
|
+
var value = [], valuelen = 0;
|
|
1961
|
+
for (var j = s; j < e; ++j) {
|
|
1962
|
+
tok = toks[j];
|
|
1963
|
+
if (tok !== ' ') {
|
|
1964
|
+
value[valuelen++] = tok;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
// One of the following is now true:
|
|
1968
|
+
// (1) e is flush with the end of the tokens as in <... style="x:y">.
|
|
1969
|
+
// (2) tok[e] points to a ';' in which case we need to consume the semi.
|
|
1970
|
+
// (3) tok[e] points to a '}' in which case we don't consume it.
|
|
1971
|
+
// (4) else there is bogus unparsed value content at toks[e:].
|
|
1972
|
+
// Allow declaration flush with end for style attr body.
|
|
1973
|
+
if (e < n) { // 2, 3, or 4
|
|
1974
|
+
do {
|
|
1975
|
+
tok = toks[e];
|
|
1976
|
+
if (tok === ';' || tok === '}') { break; }
|
|
1977
|
+
// Don't emit the property if there is questionable trailing content.
|
|
1978
|
+
valuelen = 0;
|
|
1979
|
+
} while (++e < n);
|
|
1980
|
+
if (tok === ';') {
|
|
1981
|
+
++e;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
if (valuelen && handler.declaration) {
|
|
1985
|
+
// TODO: coerce non-keyword ident tokens to quoted strings.
|
|
1986
|
+
handler.declaration(property.toLowerCase(), value);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
return e;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
parseCssDeclarations = function(cssText, handler) {
|
|
1993
|
+
var toks = lexCss(cssText);
|
|
1994
|
+
for (var i = 0, n = toks.length; i < n;) {
|
|
1995
|
+
i = toks[i] !== ' ' ? declaration(toks, i, n, handler) : i+1;
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
})();
|
|
1999
|
+
|
|
2000
|
+
// Exports for closure compiler.
|
|
2001
|
+
if (typeof window !== 'undefined') {
|
|
2002
|
+
window['parseCssStylesheet'] = parseCssStylesheet;
|
|
2003
|
+
window['parseCssDeclarations'] = parseCssDeclarations;
|
|
2004
|
+
}
|
|
2005
|
+
/*!
|
|
2006
|
+
* OpenUI5
|
|
2007
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
|
2008
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
2009
|
+
*/
|
|
2010
|
+
// Based on coding from the HTML4 Sanitizer by Google Inc.
|
|
2011
|
+
// The HTML Attributes and ELements were reorganized according to the actual HTML5 specification
|
|
2012
|
+
// from the W3C. All types and flags were reviewed again as accurately as possible with HTML4 only
|
|
2013
|
+
// elements removed, you can still see them as comments. All rules which are new or changed from the
|
|
2014
|
+
// old HTML4 file are also marked "new" within the comment. The comments also state which attributes
|
|
2015
|
+
// and elements are assigned to respective types and flags. All rules which were not 100% clear were
|
|
2016
|
+
// analyzed in a way of similarity, so for example "audio" and "video" content behaves like images etc.
|
|
2017
|
+
// URIEFFECTS state if a URL is loaded inplace within a tag where the actual document is in control
|
|
2018
|
+
// of what type of content is loaded like "image" or if a new document is loaded like with "a href".
|
|
2019
|
+
// LOADERTYPES state if content is loaded as sandboxed which means it is loaded within a specific
|
|
2020
|
+
// surroundig player like with video content for example or if it is loaded freely without restrictions.
|
|
2021
|
+
// @overrides window
|
|
2022
|
+
// @provides html4
|
|
2023
|
+
|
|
2024
|
+
var html4 = {};
|
|
2025
|
+
html4.atype = {
|
|
2026
|
+
NONE: 0,
|
|
2027
|
+
URI: 1, //action, cite, data, href, icon, manifest, poster, src
|
|
2028
|
+
URI_FRAGMENT: 11, //usemap
|
|
2029
|
+
SCRIPT: 2, //all event handlers
|
|
2030
|
+
STYLE: 3, //style
|
|
2031
|
+
ID: 4, //id
|
|
2032
|
+
IDREF: 5, //for
|
|
2033
|
+
IDREFS: 6, //headers
|
|
2034
|
+
GLOBAL_NAME: 7, //name of form, iframe, img, map, meta
|
|
2035
|
+
LOCAL_NAME: 8, //name of button, fieldset, input, keygen, object, output, param, select, textarea
|
|
2036
|
+
CLASSES: 9, //class
|
|
2037
|
+
FRAME_TARGET: 10 //formtarget, srcdoc, target
|
|
2038
|
+
};
|
|
2039
|
+
|
|
2040
|
+
html4.ATTRIBS = {
|
|
2041
|
+
'*::accesskey': 0, //NONE
|
|
2042
|
+
'*::class': 9, //CLASSES
|
|
2043
|
+
'*::contenteditable': 0, //NONE new
|
|
2044
|
+
'*::contextmenu': 0, //NONE new
|
|
2045
|
+
'*::dir': 0, //NONE
|
|
2046
|
+
'*::draggable': 0, //NONE new
|
|
2047
|
+
'*::dropzone': 0, //NONE new
|
|
2048
|
+
'*::hidden': 0, //NONE new
|
|
2049
|
+
'*::id': 4, //ID
|
|
2050
|
+
'*::lang': 0, //NONE
|
|
2051
|
+
'*::onabort': 2, //SCRIPT new
|
|
2052
|
+
'*::onblur': 2, //SCRIPT new
|
|
2053
|
+
'*::oncanplay': 2, //SCRIPT new
|
|
2054
|
+
'*::oncanplaythrough': 2, //SCRIPT new
|
|
2055
|
+
'*::onchange': 2, //SCRIPT new
|
|
2056
|
+
'*::onclick': 2, //SCRIPT
|
|
2057
|
+
'*::oncontextmenu': 2, //SCRIPT new
|
|
2058
|
+
'*::oncuechange': 2, //SCRIPT new
|
|
2059
|
+
'*::ondblclick': 2, //SCRIPT
|
|
2060
|
+
'*::ondrag': 2, //SCRIPT new
|
|
2061
|
+
'*::ondragend': 2, //SCRIPT new
|
|
2062
|
+
'*::ondragenter': 2, //SCRIPT new
|
|
2063
|
+
'*::ondragleave': 2, //SCRIPT new
|
|
2064
|
+
'*::ondragover': 2, //SCRIPT new
|
|
2065
|
+
'*::ondragstart': 2, //SCRIPT new
|
|
2066
|
+
'*::ondrop': 2, //SCRIPT new
|
|
2067
|
+
'*::ondurationchange': 2, //SCRIPT new
|
|
2068
|
+
'*::onemptied': 2, //SCRIPT new
|
|
2069
|
+
'*::onended': 2, //SCRIPT new
|
|
2070
|
+
'*::onerror': 2, //SCRIPT new
|
|
2071
|
+
'*::onfocus': 2, //SCRIPT new
|
|
2072
|
+
'*::oninput': 2, //SCRIPT new
|
|
2073
|
+
'*::oninvalid': 2, //SCRIPT new
|
|
2074
|
+
'*::onkeydown': 2, //SCRIPT
|
|
2075
|
+
'*::onkeypress': 2, //SCRIPT
|
|
2076
|
+
'*::onkeyup': 2, //SCRIPT
|
|
2077
|
+
'*::onload': 2, //SCRIPT
|
|
2078
|
+
'*::onloadeddata': 2, //SCRIPT new
|
|
2079
|
+
'*::onloadedmetadata': 2, //SCRIPT new
|
|
2080
|
+
'*::onloadstart': 2, //SCRIPT new
|
|
2081
|
+
'*::onmousedown': 2, //SCRIPT
|
|
2082
|
+
'*::onmousemove': 2, //SCRIPT
|
|
2083
|
+
'*::onmouseout': 2, //SCRIPT
|
|
2084
|
+
'*::onmouseover': 2, //SCRIPT
|
|
2085
|
+
'*::onmouseup': 2, //SCRIPT
|
|
2086
|
+
'*::onmousewheel': 2, //SCRIPT new
|
|
2087
|
+
'*::onpause': 2, //SCRIPT new
|
|
2088
|
+
'*::onplay': 2, //SCRIPT new
|
|
2089
|
+
'*::onplaying': 2, //SCRIPT new
|
|
2090
|
+
'*::onprogress': 2, //SCRIPT new
|
|
2091
|
+
'*::onratechange': 2, //SCRIPT new
|
|
2092
|
+
'*::onreadystatechange': 2, //SCRIPT new
|
|
2093
|
+
'*::onreset': 2, //SCRIPT new
|
|
2094
|
+
'*::onscroll': 2, //SCRIPT new
|
|
2095
|
+
'*::onseeked': 2, //SCRIPT new
|
|
2096
|
+
'*::onseeking': 2, //SCRIPT new
|
|
2097
|
+
'*::onselect': 2, //SCRIPT new
|
|
2098
|
+
'*::onshow': 2, //SCRIPT new
|
|
2099
|
+
'*::onstalled': 2, //SCRIPT new
|
|
2100
|
+
'*::onsubmit': 2, //SCRIPT new
|
|
2101
|
+
'*::onsuspend': 2, //SCRIPT new
|
|
2102
|
+
'*::ontimeupdate': 2, //SCRIPT new
|
|
2103
|
+
'*::onvolumechange': 2, //SCRIPT new
|
|
2104
|
+
'*::onwaiting': 2, //SCRIPT new
|
|
2105
|
+
'*::spellcheck': 0, //NONE new
|
|
2106
|
+
'*::style': 3, //STYLE
|
|
2107
|
+
'*::tabindex': 0, //NONE
|
|
2108
|
+
'*::title': 0, //NONE
|
|
2109
|
+
//--------------------- 'a::accesskey': 0, moved to global
|
|
2110
|
+
//--------------------- 'a::coords': 0,
|
|
2111
|
+
'a::href': 1, //URI
|
|
2112
|
+
'a::hreflang': 0, //NONE
|
|
2113
|
+
'a::media': 0, //NONE new
|
|
2114
|
+
//--------------------- 'a::name': 7,
|
|
2115
|
+
//--------------------- 'a::onblur': 2, moved to global
|
|
2116
|
+
//--------------------- 'a::onfocus': 2, moved to global
|
|
2117
|
+
'a::rel': 0, //NONE
|
|
2118
|
+
//--------------------- 'a::rev': 0,
|
|
2119
|
+
//--------------------- 'a::shape': 0,
|
|
2120
|
+
//--------------------- 'a::tabindex': 0, moved to global
|
|
2121
|
+
'a::target': 0, //changed to "0" because of CSN 1918585 2013, original value was 10 FRAME_TARGET but it seems uncritical
|
|
2122
|
+
'a::type': 0, //NONE
|
|
2123
|
+
//--------------------- 'area::accesskey': 0, moved to global
|
|
2124
|
+
'area::alt': 0, //NONE
|
|
2125
|
+
'area::coords': 0, //NONE
|
|
2126
|
+
'area::href': 1, //URI
|
|
2127
|
+
'area::hreflang': 0, //NONE new
|
|
2128
|
+
'area::media': 0, //NONE new
|
|
2129
|
+
//--------------------- 'area::nohref': 0,
|
|
2130
|
+
//--------------------- 'area::onblur': 2, moved to global
|
|
2131
|
+
//--------------------- 'area::onfocus': 2, moved to global
|
|
2132
|
+
'area::rel': 0, //NONE new
|
|
2133
|
+
'area::shape': 0, //NONE
|
|
2134
|
+
//--------------------- 'area::tabindex': 0, moved to global
|
|
2135
|
+
'area::target': 10, //FRAME_TARGET
|
|
2136
|
+
'area::type': 0, //NONE
|
|
2137
|
+
'audio::autoplay': 0, //NONE new
|
|
2138
|
+
'audio::controls': 0, //NONE new
|
|
2139
|
+
'audio::loop': 0, //NONE new
|
|
2140
|
+
'audio::mediagroup': 0, //NONE new
|
|
2141
|
+
'audio::preload': 0, //NONE new
|
|
2142
|
+
'audio::src': 1, //URI
|
|
2143
|
+
'base::href': 1, //URI
|
|
2144
|
+
'base::target': 10, //FRAME_TARGET
|
|
2145
|
+
//--------------------- 'bdo::dir': 0,
|
|
2146
|
+
'blockquote::cite': 1, //URI
|
|
2147
|
+
'body::onafterprint': 2, //SCRIPT new
|
|
2148
|
+
'body::onbeforeprint': 2, //SCRIPT new
|
|
2149
|
+
'body::onbeforeunload': 2, //SCRIPT new
|
|
2150
|
+
'body::onblur': 2, //SCRIPT new
|
|
2151
|
+
'body::onerror': 2, //SCRIPT new
|
|
2152
|
+
'body::onfocus': 2, //SCRIPT new
|
|
2153
|
+
'body::onhashchange': 2, //SCRIPT new
|
|
2154
|
+
'body::onload': 2, //SCRIPT new
|
|
2155
|
+
'body::onmessage': 2, //SCRIPT new
|
|
2156
|
+
'body::onoffline': 2, //SCRIPT new
|
|
2157
|
+
'body::ononline': 2, //SCRIPT new
|
|
2158
|
+
'body::onpagehide': 2, //SCRIPT new
|
|
2159
|
+
'body::onpageshow': 2, //SCRIPT new
|
|
2160
|
+
'body::onpopstate': 2, //SCRIPT new
|
|
2161
|
+
'body::onredo': 2, //SCRIPT new
|
|
2162
|
+
'body::onresize': 2, //SCRIPT new
|
|
2163
|
+
'body::onscroll': 2, //SCRIPT new
|
|
2164
|
+
'body::onstorage': 2, //SCRIPT new
|
|
2165
|
+
'body::onundo': 2, //SCRIPT new
|
|
2166
|
+
'body::onunload': 2, //SCRIPT new
|
|
2167
|
+
//--------------------- 'br::clear': 0,
|
|
2168
|
+
//--------------------- 'button::accesskey': 0, moved to global
|
|
2169
|
+
'button::autofocus': 0, //NONE new
|
|
2170
|
+
'button::disabled': 0, //NONE
|
|
2171
|
+
'button::form': 0, //NONE new
|
|
2172
|
+
'button::formaction': 1, //URI new
|
|
2173
|
+
'button::formenctype': 0, //NONE new
|
|
2174
|
+
'button::formmethod': 0, //NONE new
|
|
2175
|
+
'button::formnovalidate': 0, //NONE new
|
|
2176
|
+
'button::formtarget': 10, //FRAME_TARGET new
|
|
2177
|
+
'button::name': 8, //LOCAL_NAME
|
|
2178
|
+
//--------------------- 'button::onblur': 2,
|
|
2179
|
+
//--------------------- 'button::onfocus': 2,
|
|
2180
|
+
//--------------------- 'button::tabindex': 0, moved to global
|
|
2181
|
+
'button::type': 0, //NONE
|
|
2182
|
+
'button::value': 0, //NONE
|
|
2183
|
+
'canvas::height': 0, //NONE
|
|
2184
|
+
'canvas::width': 0, //NONE
|
|
2185
|
+
//--------------------- 'caption::align': 0,
|
|
2186
|
+
//--------------------- 'col::align': 0,
|
|
2187
|
+
//--------------------- 'col::char': 0,
|
|
2188
|
+
//--------------------- 'col::charoff': 0,
|
|
2189
|
+
'col::span': 0, //NONE
|
|
2190
|
+
//--------------------- 'col::valign': 0,
|
|
2191
|
+
//--------------------- 'col::width': 0,
|
|
2192
|
+
//--------------------- 'colgroup::align': 0,
|
|
2193
|
+
//--------------------- 'colgroup::char': 0,
|
|
2194
|
+
//--------------------- 'colgroup::charoff': 0,
|
|
2195
|
+
'colgroup::span': 0, //NONE
|
|
2196
|
+
//--------------------- 'colgroup::valign': 0,
|
|
2197
|
+
//--------------------- 'colgroup::width': 0,
|
|
2198
|
+
'command::checked': 0, //NONE new
|
|
2199
|
+
'command::disabled': 0, //NONE new
|
|
2200
|
+
'command::icon': 1, //URI new
|
|
2201
|
+
'command::label': 0, //NONE new
|
|
2202
|
+
'command::radiogroup': 0, //NONE new
|
|
2203
|
+
'command::type': 0, //NONE new
|
|
2204
|
+
'del::cite': 1, //URI
|
|
2205
|
+
'del::datetime': 0, //NONE
|
|
2206
|
+
'details::open': 0, //NONE new
|
|
2207
|
+
//--------------------- 'dir::compact': 0,
|
|
2208
|
+
//--------------------- 'div::align': 0,
|
|
2209
|
+
//--------------------- 'dl::compact': 0,
|
|
2210
|
+
'embed::height': 0, //NONE new
|
|
2211
|
+
'embed::src': 1, //URI new
|
|
2212
|
+
'embed::type': 0, //NONE new
|
|
2213
|
+
'embed::width': 0, //NONE new
|
|
2214
|
+
'fieldset::disabled': 0, //NONE new
|
|
2215
|
+
'fieldset::form': 0, //NONE new
|
|
2216
|
+
'fieldset::name': 8, //LOCAL_NAME new
|
|
2217
|
+
//--------------------- 'font::color': 0,
|
|
2218
|
+
//--------------------- 'font::face': 0,
|
|
2219
|
+
//--------------------- 'font::size': 0,
|
|
2220
|
+
//--------------------- 'form::accept': 0,
|
|
2221
|
+
'form::accept-charset': 0, //NONE
|
|
2222
|
+
'form::action': 1, //URI
|
|
2223
|
+
'form::autocomplete': 0, //NONE
|
|
2224
|
+
'form::enctype': 0, //NONE
|
|
2225
|
+
'form::method': 0, //NONE
|
|
2226
|
+
'form::name': 7, //GLOBAL_NAME
|
|
2227
|
+
'form::novalidate': 0, //NONE new
|
|
2228
|
+
//--------------------- 'form::onreset': 2,
|
|
2229
|
+
//--------------------- 'form::onsubmit': 2,
|
|
2230
|
+
'form::target': 10, //FRAME_TARGET
|
|
2231
|
+
//--------------------- 'h1::align': 0,
|
|
2232
|
+
//--------------------- 'h2::align': 0,
|
|
2233
|
+
//--------------------- 'h3::align': 0,
|
|
2234
|
+
//--------------------- 'h4::align': 0,
|
|
2235
|
+
//--------------------- 'h5::align': 0,
|
|
2236
|
+
//--------------------- 'h6::align': 0,
|
|
2237
|
+
//--------------------- 'hr::align': 0,
|
|
2238
|
+
//--------------------- 'hr::noshade': 0,
|
|
2239
|
+
//--------------------- 'hr::size': 0,
|
|
2240
|
+
//--------------------- 'hr::width': 0,
|
|
2241
|
+
'html:: manifest': 1, //URI new
|
|
2242
|
+
//--------------------- 'iframe::align': 0,
|
|
2243
|
+
//--------------------- 'iframe::frameborder': 0,
|
|
2244
|
+
'iframe::height': 0, //NONE
|
|
2245
|
+
//--------------------- 'iframe::marginheight': 0,
|
|
2246
|
+
//--------------------- 'iframe::marginwidth': 0,
|
|
2247
|
+
'iframe::name': 7, //GLOBAL_NAME new
|
|
2248
|
+
'iframe::sandbox': 0, //NONE new
|
|
2249
|
+
'iframe::seamless': 0, //NONE new
|
|
2250
|
+
'iframe::src': 1, //URI new
|
|
2251
|
+
'iframe::srcdoc': 10, //FRAME_TARGET new
|
|
2252
|
+
'iframe::width': 0, //NONE
|
|
2253
|
+
//--------------------- 'img::align': 0,
|
|
2254
|
+
'img::alt': 0, //NONE
|
|
2255
|
+
//--------------------- 'img::border': 0,
|
|
2256
|
+
'img::height': 0, //NONE
|
|
2257
|
+
//--------------------- 'img::hspace': 0,
|
|
2258
|
+
'img::ismap': 0, //NONE
|
|
2259
|
+
'img::name': 7, //GLOBAL_NAME
|
|
2260
|
+
'img::src': 1, //URI
|
|
2261
|
+
'img::usemap': 11, //URI_FRAGMENT
|
|
2262
|
+
//--------------------- 'img::vspace': 0,
|
|
2263
|
+
'img::width': 0, //NONE
|
|
2264
|
+
'input::accept': 0, //NONE
|
|
2265
|
+
//--------------------- 'input::accesskey': 0, moved to global
|
|
2266
|
+
//--------------------- 'input::align': 0,
|
|
2267
|
+
'input::alt': 0, //NONE
|
|
2268
|
+
'input::autocomplete': 0, //NONE
|
|
2269
|
+
'input::autofocus': 0, //NONE new
|
|
2270
|
+
'input::checked': 0, //NONE
|
|
2271
|
+
'input::dirname': 0, //NONE new
|
|
2272
|
+
'input::disabled': 0, //NONE
|
|
2273
|
+
'input::form': 0, //NONE new
|
|
2274
|
+
'input::formaction': 1, //URI new
|
|
2275
|
+
'input::formenctype': 0, //NONE new
|
|
2276
|
+
'input::formmethod': 0, //NONE new
|
|
2277
|
+
'input::formnovalidate': 0, //NONE new
|
|
2278
|
+
'input::formtarget': 10, //FRAME_TARGET new
|
|
2279
|
+
'input::height': 0, //NONE new
|
|
2280
|
+
//--------------------- 'input::ismap': 0,
|
|
2281
|
+
'input::list': 0, //NONE new
|
|
2282
|
+
'input::max': 0, //NONE new
|
|
2283
|
+
'input::maxlength': 0, //NONE
|
|
2284
|
+
'input::min': 0, //NONE new
|
|
2285
|
+
'input::multiple': 0, //NONE new
|
|
2286
|
+
'input::name': 8, //LOCAL_NAME
|
|
2287
|
+
//--------------------- 'input::onblur': 2,
|
|
2288
|
+
//--------------------- 'input::onchange': 2,
|
|
2289
|
+
//--------------------- 'input::onfocus': 2,
|
|
2290
|
+
//--------------------- 'input::onselect': 2,
|
|
2291
|
+
'input::pattern': 0, //NONE new
|
|
2292
|
+
'input::placeholder': 0, //NONE new
|
|
2293
|
+
'input::readonly': 0, //NONE
|
|
2294
|
+
'input::required': 0, //NONE new
|
|
2295
|
+
'input::step': 0, //NONE new
|
|
2296
|
+
'input::size': 0, //NONE
|
|
2297
|
+
'input::src': 1, //URI
|
|
2298
|
+
//--------------------- 'input::tabindex': 0, moved to global
|
|
2299
|
+
'input::type': 0, //NONE
|
|
2300
|
+
//--------------------- 'input::usemap': 11,
|
|
2301
|
+
'input::value': 0, //NONE
|
|
2302
|
+
'input::width': 0, //NONE new
|
|
2303
|
+
'ins::cite': 1, //URI
|
|
2304
|
+
'ins::datetime': 0, //NONE
|
|
2305
|
+
//--------------------- 'label::accesskey': 0, moved to global
|
|
2306
|
+
'keygen::autofocus': 0, //NONE new
|
|
2307
|
+
'keygen::challenge': 0, //NONE new
|
|
2308
|
+
'keygen::disabled': 0, //NONE new
|
|
2309
|
+
'keygen::form': 0, //NONE new
|
|
2310
|
+
'keygen::keytype': 0, //NONE new
|
|
2311
|
+
'keygen::name': 8, //LOCAL_NAME new
|
|
2312
|
+
'label::for': 5, //IDREF
|
|
2313
|
+
'label::form': 0, //NONE new
|
|
2314
|
+
//--------------------- 'label::onblur': 2,
|
|
2315
|
+
//--------------------- 'label::onfocus': 2,
|
|
2316
|
+
//--------------------- 'legend::accesskey': 0, moved to global
|
|
2317
|
+
//--------------------- 'legend::align': 0,
|
|
2318
|
+
//--------------------- 'li::type': 0,
|
|
2319
|
+
'link::href': 1, //URI new
|
|
2320
|
+
'link::hreflang': 0, //NONE new
|
|
2321
|
+
'link::media': 0, //NONE new
|
|
2322
|
+
'link::rel': 0, //NONE new
|
|
2323
|
+
'link::sizes': 0, //NONE new
|
|
2324
|
+
'link::type': 0, //NONE new
|
|
2325
|
+
'li::value': 0, //NONE new
|
|
2326
|
+
'map::name': 7, //GLOBAL_NAME
|
|
2327
|
+
//--------------------- 'menu::compact': 0,
|
|
2328
|
+
'menu::label': 0, //NONE new
|
|
2329
|
+
'menu::type': 0, //NONE new
|
|
2330
|
+
'meta::charset': 0, //NONE new
|
|
2331
|
+
'meta::content': 0, //NONE new
|
|
2332
|
+
'meta::http-equiv': 0, //NONE new
|
|
2333
|
+
'meta::name': 7, //GLOBAL_NAME new
|
|
2334
|
+
'meter::form': 0, //NONE new
|
|
2335
|
+
'meter::high': 0, //NONE new
|
|
2336
|
+
'meter::low': 0, //NONE new
|
|
2337
|
+
'meter::max': 0, //NONE new
|
|
2338
|
+
'meter::min': 0, //NONE new
|
|
2339
|
+
'meter::optimum': 0, //NONE new
|
|
2340
|
+
'meter::value': 0, //NONE new
|
|
2341
|
+
'object::data': 1, //URI new
|
|
2342
|
+
'object::form': 0, //NONE new
|
|
2343
|
+
'object::height': 0, //NONE new
|
|
2344
|
+
'object::name': 8, //LOCAL_NAME new
|
|
2345
|
+
'object::type': 0, //NONE new
|
|
2346
|
+
'object::usemap': 11, //URI_FRAGMENT new
|
|
2347
|
+
'object::width': 0, //NONE new
|
|
2348
|
+
//--------------------- 'ol::compact': 0,
|
|
2349
|
+
'ol::reversed': 0, //NONE new
|
|
2350
|
+
'ol::start': 0, //NONE
|
|
2351
|
+
//--------------------- 'ol::type': 0,
|
|
2352
|
+
'optgroup::disabled': 0, //NONE
|
|
2353
|
+
'optgroup::label': 0, //NONE
|
|
2354
|
+
'option::disabled': 0, //NONE
|
|
2355
|
+
'option::label': 0, //NONE
|
|
2356
|
+
'option::selected': 0, //NONE
|
|
2357
|
+
'option::value': 0, //NONE
|
|
2358
|
+
'output::for': 5, //IDREF new
|
|
2359
|
+
'output::form': 0, //NONE new
|
|
2360
|
+
'output::name': 8, //LOCAL_NAME new
|
|
2361
|
+
//--------------------- 'p::align': 0,
|
|
2362
|
+
'param::name': 8, //LOCAL_NAME new
|
|
2363
|
+
'param::value': 0, //NONE new
|
|
2364
|
+
'progress::form': 0, //NONE new
|
|
2365
|
+
'progress::max': 0, //NONE new
|
|
2366
|
+
'progress::value': 0, //NONE new
|
|
2367
|
+
//--------------------- 'pre::width': 0,
|
|
2368
|
+
'q::cite': 1, //URI
|
|
2369
|
+
'script::async': 0, //NONE new
|
|
2370
|
+
'script::charset': 0, //NONE new
|
|
2371
|
+
'script::defer': 0, //NONE new
|
|
2372
|
+
'script::src': 1, //URI new
|
|
2373
|
+
'script::type': 0, //NONE new
|
|
2374
|
+
'select::autofocus': 0, //NONE new
|
|
2375
|
+
'select::disabled': 0, //NONE
|
|
2376
|
+
'select::form': 0, //NONE new
|
|
2377
|
+
'select::multiple': 0, //NONE
|
|
2378
|
+
'select::name': 8, //LOCAL_NAME
|
|
2379
|
+
//--------------------- 'select::onblur': 2,
|
|
2380
|
+
//--------------------- 'select::onchange': 2,
|
|
2381
|
+
//--------------------- 'select::onfocus': 2,
|
|
2382
|
+
'select::required': 0, //NONE new
|
|
2383
|
+
'select::size': 0, //NONE
|
|
2384
|
+
//--------------------- 'select::tabindex': 0, moved to global
|
|
2385
|
+
'source::media': 0, //NONE new
|
|
2386
|
+
'source::src': 1, //URI new
|
|
2387
|
+
'source::type': 0, //NONE new
|
|
2388
|
+
'style::media': 0, //NONE new
|
|
2389
|
+
'style::scoped': 0, //NONE new
|
|
2390
|
+
'style::type': 0, //NONE new
|
|
2391
|
+
//--------------------- 'table::align': 0,
|
|
2392
|
+
//--------------------- 'table::bgcolor': 0,
|
|
2393
|
+
'table::border': 0, //NONE
|
|
2394
|
+
//--------------------- 'table::cellpadding': 0,
|
|
2395
|
+
//--------------------- 'table::cellspacing': 0,
|
|
2396
|
+
//--------------------- 'table::frame': 0,
|
|
2397
|
+
//--------------------- 'table::rules': 0,
|
|
2398
|
+
//--------------------- 'table::summary': 0,
|
|
2399
|
+
//--------------------- 'table::width': 0,
|
|
2400
|
+
//--------------------- 'tbody::align': 0,
|
|
2401
|
+
//--------------------- 'tbody::char': 0,
|
|
2402
|
+
//--------------------- 'tbody::charoff': 0,
|
|
2403
|
+
//--------------------- 'tbody::valign': 0,
|
|
2404
|
+
//--------------------- 'td::abbr': 0,
|
|
2405
|
+
//--------------------- 'td::align': 0,
|
|
2406
|
+
//--------------------- 'td::axis': 0,
|
|
2407
|
+
//--------------------- 'td::bgcolor': 0,
|
|
2408
|
+
//--------------------- 'td::char': 0,
|
|
2409
|
+
//--------------------- 'td::charoff': 0,
|
|
2410
|
+
'td::colspan': 0, //NONE
|
|
2411
|
+
'td::headers': 6, //IDREFS
|
|
2412
|
+
//--------------------- 'td::height': 0,
|
|
2413
|
+
//--------------------- 'td::nowrap': 0,
|
|
2414
|
+
'td::rowspan': 0, //NONE
|
|
2415
|
+
//--------------------- 'td::scope': 0,
|
|
2416
|
+
//--------------------- 'td::valign': 0,
|
|
2417
|
+
//--------------------- 'td::width': 0,
|
|
2418
|
+
//--------------------- 'textarea::accesskey': 0, moved to global
|
|
2419
|
+
'textarea::autofocus': 0, //NONE new
|
|
2420
|
+
'textarea::cols': 0, //NONE
|
|
2421
|
+
'textarea::disabled': 0, //NONE
|
|
2422
|
+
'textarea::form': 0, //NONE new
|
|
2423
|
+
'textarea::maxlength': 0, //NONE new
|
|
2424
|
+
'textarea::name': 8, //LOCAL_NAME
|
|
2425
|
+
//--------------------- 'textarea::onblur': 2,
|
|
2426
|
+
//--------------------- 'textarea::onchange': 2,
|
|
2427
|
+
//--------------------- 'textarea::onfocus': 2,
|
|
2428
|
+
//--------------------- 'textarea::onselect': 2,
|
|
2429
|
+
'textarea::placeholder': 0, //NONE new
|
|
2430
|
+
'textarea::readonly': 0, //NONE
|
|
2431
|
+
'textarea::required': 0, //NONE new
|
|
2432
|
+
'textarea::rows': 0, //NONE
|
|
2433
|
+
'textarea::wrap': 0, //NONE new
|
|
2434
|
+
//--------------------- 'textarea::tabindex': 0, moved to global
|
|
2435
|
+
//--------------------- 'tfoot::align': 0,
|
|
2436
|
+
//--------------------- 'tfoot::char': 0,
|
|
2437
|
+
//--------------------- 'tfoot::charoff': 0,
|
|
2438
|
+
//--------------------- 'tfoot::valign': 0,
|
|
2439
|
+
//--------------------- 'th::abbr': 0,
|
|
2440
|
+
//--------------------- 'th::align': 0,
|
|
2441
|
+
//--------------------- 'th::axis': 0,
|
|
2442
|
+
//--------------------- 'th::bgcolor': 0,
|
|
2443
|
+
//--------------------- 'th::char': 0,
|
|
2444
|
+
//--------------------- 'th::charoff': 0,
|
|
2445
|
+
'th::colspan': 0, //NONE
|
|
2446
|
+
'th::headers': 6, //IDREFS
|
|
2447
|
+
//--------------------- 'th::height': 0,
|
|
2448
|
+
//--------------------- 'th::nowrap': 0,
|
|
2449
|
+
'th::rowspan': 0, //NONE
|
|
2450
|
+
'th::scope': 0, //NONE
|
|
2451
|
+
//--------------------- 'th::valign': 0,
|
|
2452
|
+
//--------------------- 'th::width': 0,
|
|
2453
|
+
//--------------------- 'thead::align': 0,
|
|
2454
|
+
//--------------------- 'thead::char': 0,
|
|
2455
|
+
//--------------------- 'thead::charoff': 0,
|
|
2456
|
+
//--------------------- 'thead::valign': 0,
|
|
2457
|
+
'time::datetime': 0, //NONE new
|
|
2458
|
+
'time::pubdate': 0, //NONE new
|
|
2459
|
+
//--------------------- 'tr::align': 0,
|
|
2460
|
+
//--------------------- 'tr::bgcolor': 0,
|
|
2461
|
+
//--------------------- 'tr::char': 0,
|
|
2462
|
+
//--------------------- 'tr::charoff': 0,
|
|
2463
|
+
//--------------------- 'tr::valign': 0,
|
|
2464
|
+
'track::default': 0, //NONE new
|
|
2465
|
+
'track::kind': 0, //NONE new
|
|
2466
|
+
'track::label': 0, //NONE new
|
|
2467
|
+
'track::src': 1, //URI new
|
|
2468
|
+
'track::srclang': 0, //NONE new
|
|
2469
|
+
//--------------------- 'ul::compact': 0,
|
|
2470
|
+
//--------------------- 'ul::type': 0
|
|
2471
|
+
'video::autoplay': 0, //NONE new
|
|
2472
|
+
'video::controls': 0, //NONE new
|
|
2473
|
+
'video::height': 0, //NONE new
|
|
2474
|
+
'video::loop': 0, //NONE new
|
|
2475
|
+
'video::mediagroup': 0, //NONE new
|
|
2476
|
+
'video::poster': 1, //URI new
|
|
2477
|
+
'video::preload': 0, //NONE new
|
|
2478
|
+
'video::src': 1, //URI new
|
|
2479
|
+
'video::width': 0 //NONE new
|
|
2480
|
+
};
|
|
2481
|
+
html4.eflags = {
|
|
2482
|
+
OPTIONAL_ENDTAG: 1,
|
|
2483
|
+
EMPTY: 2,
|
|
2484
|
+
CDATA: 4,
|
|
2485
|
+
RCDATA: 8,
|
|
2486
|
+
UNSAFE: 16,
|
|
2487
|
+
FOLDABLE: 32,
|
|
2488
|
+
SCRIPT: 64,
|
|
2489
|
+
STYLE: 128
|
|
2490
|
+
};
|
|
2491
|
+
html4.ELEMENTS = {
|
|
2492
|
+
'a': 0,
|
|
2493
|
+
'abbr': 0,
|
|
2494
|
+
//--------------------- 'acronym': 0,
|
|
2495
|
+
'address': 0,
|
|
2496
|
+
//--------------------- 'applet': 16,
|
|
2497
|
+
'area': 2, //EMPTY
|
|
2498
|
+
'article': 0, //new
|
|
2499
|
+
'aside': 0, //new
|
|
2500
|
+
'audio': 0, //new
|
|
2501
|
+
'b': 0,
|
|
2502
|
+
'base': 18, //EMPTY, UNSAFE
|
|
2503
|
+
//--------------------- 'basefont': 18,
|
|
2504
|
+
'bdi': 0, //new
|
|
2505
|
+
'bdo': 0,
|
|
2506
|
+
//--------------------- 'big': 0,
|
|
2507
|
+
'blockquote': 0,
|
|
2508
|
+
'body': 49, //OPTIONAL_ENDTAG, UNSAFE, FOLDABLE
|
|
2509
|
+
'br': 2, //EMPTY
|
|
2510
|
+
'button': 0,
|
|
2511
|
+
'canvas': 0,
|
|
2512
|
+
'caption': 0,
|
|
2513
|
+
//--------------------- 'center': 0,
|
|
2514
|
+
'cite': 0,
|
|
2515
|
+
'code': 0,
|
|
2516
|
+
'col': 2, //EMPTY
|
|
2517
|
+
'colgroup': 1, //OPTIONAL_ENDTAG
|
|
2518
|
+
'command': 2, //EMPTY new
|
|
2519
|
+
'datalist': 0, //new
|
|
2520
|
+
'dd': 1, //OPTIONAL_ENDTAG
|
|
2521
|
+
'del': 0,
|
|
2522
|
+
'details': 0, //new
|
|
2523
|
+
'dfn': 0,
|
|
2524
|
+
//--------------------- 'dir': 0,
|
|
2525
|
+
'div': 0,
|
|
2526
|
+
'dl': 0,
|
|
2527
|
+
'dt': 1, //OPTIONAL_ENDTAG
|
|
2528
|
+
'em': 0,
|
|
2529
|
+
'embed': 18, //EMPTY, UNSAFE new
|
|
2530
|
+
'fieldset': 0,
|
|
2531
|
+
'figcaption': 0, //new
|
|
2532
|
+
'figure': 0, //new
|
|
2533
|
+
//--------------------- 'font': 0,
|
|
2534
|
+
'footer': 0, //new
|
|
2535
|
+
'form': 0,
|
|
2536
|
+
//--------------------- 'frame': 18,
|
|
2537
|
+
//--------------------- 'frameset': 16,
|
|
2538
|
+
'h1': 0,
|
|
2539
|
+
'h2': 0,
|
|
2540
|
+
'h3': 0,
|
|
2541
|
+
'h4': 0,
|
|
2542
|
+
'h5': 0,
|
|
2543
|
+
'h6': 0,
|
|
2544
|
+
'head': 49, //OPTIONAL_ENDTAG, UNSAFE, FOLDABLE
|
|
2545
|
+
'header': 0, //new
|
|
2546
|
+
'hgroup': 0, //new
|
|
2547
|
+
'hr': 2, //EMPTY
|
|
2548
|
+
'html': 49, //OPTIONAL_ENDTAG, UNSAFE, FOLDABLE
|
|
2549
|
+
'i': 0,
|
|
2550
|
+
'iframe': 4, //CDATA
|
|
2551
|
+
'img': 2,//EMPTY
|
|
2552
|
+
'input': 2, //EMPTY
|
|
2553
|
+
'ins': 0,
|
|
2554
|
+
//--------------------- 'isindex': 18,
|
|
2555
|
+
'kbd': 0,
|
|
2556
|
+
'keygen': 2, //EMPTY new
|
|
2557
|
+
'label': 0,
|
|
2558
|
+
'legend': 0,
|
|
2559
|
+
'li': 1, //OPTIONAL_ENDTAG
|
|
2560
|
+
'link': 18, //EMPTY, UNSAFE
|
|
2561
|
+
'map': 0,
|
|
2562
|
+
'mark': 0, //new
|
|
2563
|
+
'menu': 0,
|
|
2564
|
+
'meta': 18, //EMPTY, UNSAFE
|
|
2565
|
+
'meter': 0, //new
|
|
2566
|
+
'nav': 0,
|
|
2567
|
+
//--------------------- 'nobr': 0,
|
|
2568
|
+
//--------------------- 'noembed': 4,
|
|
2569
|
+
//--------------------- 'noframes': 20,
|
|
2570
|
+
'noscript': 20, //CDATA, UNSAFE
|
|
2571
|
+
'object': 16, //UNSAFE
|
|
2572
|
+
'ol': 0,
|
|
2573
|
+
'optgroup': 1, //OPTIONAL_ENDTAG new !!!!vorher 0
|
|
2574
|
+
'option': 1, //OPTIONAL_ENDTAG
|
|
2575
|
+
'output': 0, //new
|
|
2576
|
+
'p': 1, //OPTIONAL_ENDTAG
|
|
2577
|
+
'param': 18, //EMPTY, UNSAFE
|
|
2578
|
+
'pre': 0,
|
|
2579
|
+
'progress': 0, //new
|
|
2580
|
+
'q': 0,
|
|
2581
|
+
'rp': 1, //OPTIONAL_ENDTAG new
|
|
2582
|
+
'rt': 1, //OPTIONAL_ENDTAG new
|
|
2583
|
+
'ruby': 0, //new
|
|
2584
|
+
's': 0,
|
|
2585
|
+
'samp': 0,
|
|
2586
|
+
'script': 84, //CDATA, UNSAFE, SCRIPT
|
|
2587
|
+
'section': 0, //new
|
|
2588
|
+
'select': 0,
|
|
2589
|
+
'small': 0,
|
|
2590
|
+
'source': 2, //EMPTY new
|
|
2591
|
+
'span': 0,
|
|
2592
|
+
//--------------------- 'strike': 0,
|
|
2593
|
+
'strong': 0,
|
|
2594
|
+
'style': 148, //CDATA, UNSAFE, STYLE
|
|
2595
|
+
'sub': 0,
|
|
2596
|
+
'summary': 0, //new
|
|
2597
|
+
'sup': 0,
|
|
2598
|
+
'table': 0,
|
|
2599
|
+
'tbody': 1, //OPTIONAL_ENDTAG
|
|
2600
|
+
'td': 1, //OPTIONAL_ENDTAG
|
|
2601
|
+
'textarea': 8, //RCDATA
|
|
2602
|
+
'tfoot': 1, //OPTIONAL_ENDTAG
|
|
2603
|
+
'th': 1, //OPTIONAL_ENDTAG
|
|
2604
|
+
'thead': 1, //OPTIONAL_ENDTAG
|
|
2605
|
+
'time': 0, //new
|
|
2606
|
+
'title': 24, //RCDATA, UNSAFE
|
|
2607
|
+
'tr': 1, //OPTIONAL_ENDTAG
|
|
2608
|
+
'track': 2, //EMPTY new
|
|
2609
|
+
//--------------------- 'tt': 0,
|
|
2610
|
+
'u': 0,
|
|
2611
|
+
'ul': 0,
|
|
2612
|
+
'var': 0,
|
|
2613
|
+
'video': 0, //new
|
|
2614
|
+
'wbr': 2 //EMPTY new
|
|
2615
|
+
};
|
|
2616
|
+
html4.ueffects = {
|
|
2617
|
+
NOT_LOADED: 0,
|
|
2618
|
+
SAME_DOCUMENT: 1,
|
|
2619
|
+
NEW_DOCUMENT: 2
|
|
2620
|
+
};
|
|
2621
|
+
html4.URIEFFECTS = {
|
|
2622
|
+
'a::href': 2, //NEW_DOCUMENT
|
|
2623
|
+
'area::href': 2, //NEW_DOCUMENT
|
|
2624
|
+
'audio::src': 1, //SAME_DOCUMENT new
|
|
2625
|
+
'base::href':2, //NEW_DOCUMENT new
|
|
2626
|
+
'blockquote::cite': 0, //NOT_LOADED
|
|
2627
|
+
//--------------------- 'body::background': 1,
|
|
2628
|
+
'button::formaction': 2, //NEW_DOCUMENT new
|
|
2629
|
+
'command::icon': 1, //SAME_DOCUMENT new
|
|
2630
|
+
'del::cite': 0, //NOT_LOADED
|
|
2631
|
+
'embed::src': 1, //SAME_DOCUMENT new
|
|
2632
|
+
'form::action': 2, //NEW_DOCUMENT
|
|
2633
|
+
'html:: manifest': 1, //SAME_DOCUMENT new
|
|
2634
|
+
'iframe::src': 1, //SAME_DOCUMENT new
|
|
2635
|
+
'img::src': 1, //SAME_DOCUMENT
|
|
2636
|
+
'input::formaction': 2, //NEW_DOCUMENT new
|
|
2637
|
+
'input::src': 1, //SAME_DOCUMENT
|
|
2638
|
+
'ins::cite': 0, //NOT_LOADED
|
|
2639
|
+
'link::href': 2, //NEW_DOCUMENT new
|
|
2640
|
+
'object::data': 1, //SAME_DOCUMENT new
|
|
2641
|
+
'q::cite': 0, //NOT_LOADED
|
|
2642
|
+
'script::src': 1, //SAME_DOCUMENT new
|
|
2643
|
+
'source::src': 1, //SAME_DOCUMENT new
|
|
2644
|
+
'track::src': 1, //SAME_DOCUMENT new
|
|
2645
|
+
'video::poster': 1, //SAME_DOCUMENT new
|
|
2646
|
+
'video::src': 1 //SAME_DOCUMENT new
|
|
2647
|
+
};
|
|
2648
|
+
html4.ltypes = {
|
|
2649
|
+
UNSANDBOXED: 2,
|
|
2650
|
+
SANDBOXED: 1,
|
|
2651
|
+
DATA: 0
|
|
2652
|
+
};
|
|
2653
|
+
html4.LOADERTYPES = {
|
|
2654
|
+
'a::href': 2, //UNSANDBOXED
|
|
2655
|
+
'area::href': 2, //UNSANDBOXED
|
|
2656
|
+
'audio::src': 1, //SANDBOXED new
|
|
2657
|
+
'base::href': 2, //UNSANDBOXED new
|
|
2658
|
+
'blockquote::cite': 2, //UNSANDBOXED
|
|
2659
|
+
//--------------------- 'body::background': 1,
|
|
2660
|
+
'button::formaction': 2, //UNSANDBOXED new
|
|
2661
|
+
'command::icon': 1, //SANDBOXED new
|
|
2662
|
+
'del::cite': 2, //UNSANDBOXED
|
|
2663
|
+
'embed::src': 1, //SANDBOXED new
|
|
2664
|
+
'form::action': 2, //UNSANDBOXED
|
|
2665
|
+
'html:: manifest': 1, //SANDBOXED new
|
|
2666
|
+
'iframe::src': 1, //SANDBOXED new
|
|
2667
|
+
'img::src': 1, //SANDBOXED
|
|
2668
|
+
'input::formaction': 2, //UNSANDBOXED new
|
|
2669
|
+
'input::src': 1, //SANDBOXED
|
|
2670
|
+
'ins::cite': 2, //UNSANDBOXED
|
|
2671
|
+
'link::href': 2, //UNSANDBOXED new
|
|
2672
|
+
'object::data': 0, //DATA new
|
|
2673
|
+
'q::cite': 2, //UNSANDBOXED
|
|
2674
|
+
'script::src': 1, //SANDBOXED new
|
|
2675
|
+
'source::src': 1, //SANDBOXED new
|
|
2676
|
+
'track::src': 1, //SANDBOXED new
|
|
2677
|
+
'video::poster': 1, //SANDBOXED new
|
|
2678
|
+
'video::src': 1 //SANDBOXED new
|
|
2679
|
+
};if (typeof window !== 'undefined') {
|
|
2680
|
+
window['html4'] = html4;
|
|
2681
|
+
}// Copyright (C) 2006 Google Inc.
|
|
2682
|
+
//
|
|
2683
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2684
|
+
// you may not use this file except in compliance with the License.
|
|
2685
|
+
// You may obtain a copy of the License at
|
|
2686
|
+
//
|
|
2687
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
2688
|
+
//
|
|
2689
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
2690
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
2691
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2692
|
+
// See the License for the specific language governing permissions and
|
|
2693
|
+
// limitations under the License.
|
|
2694
|
+
|
|
2695
|
+
/**
|
|
2696
|
+
* @fileoverview
|
|
2697
|
+
* An HTML sanitizer that can satisfy a variety of security policies.
|
|
2698
|
+
*
|
|
2699
|
+
* <p>
|
|
2700
|
+
* The HTML sanitizer is built around a SAX parser and HTML element and
|
|
2701
|
+
* attributes schemas.
|
|
2702
|
+
*
|
|
2703
|
+
* If the cssparser is loaded, inline styles are sanitized using the
|
|
2704
|
+
* css property and value schemas. Else they are remove during
|
|
2705
|
+
* sanitization.
|
|
2706
|
+
*
|
|
2707
|
+
* If it exists, uses parseCssDeclarations, sanitizeCssProperty, cssSchema
|
|
2708
|
+
*
|
|
2709
|
+
* @author mikesamuel@gmail.com
|
|
2710
|
+
* @author jasvir@gmail.com
|
|
2711
|
+
* \@requires html4
|
|
2712
|
+
* \@overrides window
|
|
2713
|
+
* \@provides html, html_sanitize
|
|
2714
|
+
*/
|
|
2715
|
+
|
|
2716
|
+
/**
|
|
2717
|
+
* \@namespace
|
|
2718
|
+
*/
|
|
2719
|
+
var html = (function(html4) {
|
|
2720
|
+
|
|
2721
|
+
// For closure compiler
|
|
2722
|
+
var parseCssDeclarations, sanitizeCssProperty, cssSchema;
|
|
2723
|
+
if ('undefined' !== typeof window) {
|
|
2724
|
+
parseCssDeclarations = window['parseCssDeclarations'];
|
|
2725
|
+
sanitizeCssProperty = window['sanitizeCssProperty'];
|
|
2726
|
+
cssSchema = window['cssSchema'];
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
var lcase;
|
|
2730
|
+
// The below may not be true on browsers in the Turkish locale.
|
|
2731
|
+
if ('script' === 'SCRIPT'.toLowerCase()) {
|
|
2732
|
+
lcase = function(s) { return s.toLowerCase(); };
|
|
2733
|
+
} else {
|
|
2734
|
+
/**
|
|
2735
|
+
* {\@updoc
|
|
2736
|
+
* $ lcase('SCRIPT')
|
|
2737
|
+
* # 'script'
|
|
2738
|
+
* $ lcase('script')
|
|
2739
|
+
* # 'script'
|
|
2740
|
+
* }
|
|
2741
|
+
*/
|
|
2742
|
+
lcase = function(s) {
|
|
2743
|
+
return s.replace(
|
|
2744
|
+
/[A-Z]/g,
|
|
2745
|
+
function(ch) {
|
|
2746
|
+
return String.fromCharCode(ch.charCodeAt(0) | 32);
|
|
2747
|
+
});
|
|
2748
|
+
};
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
// The keys of this object must be 'quoted' or JSCompiler will mangle them!
|
|
2752
|
+
var ENTITIES = {
|
|
2753
|
+
'lt': '<',
|
|
2754
|
+
'gt': '>',
|
|
2755
|
+
'amp': '&',
|
|
2756
|
+
'nbsp': '\xA0',
|
|
2757
|
+
'quot': '"',
|
|
2758
|
+
'apos': '\''
|
|
2759
|
+
};
|
|
2760
|
+
|
|
2761
|
+
var decimalEscapeRe = /^#(\d+)$/;
|
|
2762
|
+
var hexEscapeRe = /^#x([0-9A-Fa-f]+)$/;
|
|
2763
|
+
/**
|
|
2764
|
+
* Decodes an HTML entity.
|
|
2765
|
+
*
|
|
2766
|
+
* {\@updoc
|
|
2767
|
+
* $ lookupEntity('lt')
|
|
2768
|
+
* # '<'
|
|
2769
|
+
* $ lookupEntity('GT')
|
|
2770
|
+
* # '>'
|
|
2771
|
+
* $ lookupEntity('amp')
|
|
2772
|
+
* # '&'
|
|
2773
|
+
* $ lookupEntity('nbsp')
|
|
2774
|
+
* # '\xA0'
|
|
2775
|
+
* $ lookupEntity('apos')
|
|
2776
|
+
* # "'"
|
|
2777
|
+
* $ lookupEntity('quot')
|
|
2778
|
+
* # '"'
|
|
2779
|
+
* $ lookupEntity('#xa')
|
|
2780
|
+
* # '\n'
|
|
2781
|
+
* $ lookupEntity('#10')
|
|
2782
|
+
* # '\n'
|
|
2783
|
+
* $ lookupEntity('#x0a')
|
|
2784
|
+
* # '\n'
|
|
2785
|
+
* $ lookupEntity('#010')
|
|
2786
|
+
* # '\n'
|
|
2787
|
+
* $ lookupEntity('#x00A')
|
|
2788
|
+
* # '\n'
|
|
2789
|
+
* $ lookupEntity('Pi') // Known failure
|
|
2790
|
+
* # '\u03A0'
|
|
2791
|
+
* $ lookupEntity('pi') // Known failure
|
|
2792
|
+
* # '\u03C0'
|
|
2793
|
+
* }
|
|
2794
|
+
*
|
|
2795
|
+
* @param {string} name the content between the '&' and the ';'.
|
|
2796
|
+
* @return {string} a single unicode code-point as a string.
|
|
2797
|
+
*/
|
|
2798
|
+
function lookupEntity(name) {
|
|
2799
|
+
name = lcase(name); // TODO: π is different from Π
|
|
2800
|
+
if (ENTITIES.hasOwnProperty(name)) { return ENTITIES[name]; }
|
|
2801
|
+
var m = name.match(decimalEscapeRe);
|
|
2802
|
+
if (m) {
|
|
2803
|
+
return String.fromCharCode(parseInt(m[1], 10));
|
|
2804
|
+
} else if (!!(m = name.match(hexEscapeRe))) {
|
|
2805
|
+
return String.fromCharCode(parseInt(m[1], 16));
|
|
2806
|
+
}
|
|
2807
|
+
return '';
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
function decodeOneEntity(_, name) {
|
|
2811
|
+
return lookupEntity(name);
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
var nulRe = /\0/g;
|
|
2815
|
+
function stripNULs(s) {
|
|
2816
|
+
return s.replace(nulRe, '');
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
var entityRe = /&(#\d+|#x[0-9A-Fa-f]+|\w+);/g;
|
|
2820
|
+
/**
|
|
2821
|
+
* The plain text of a chunk of HTML CDATA which possibly containing.
|
|
2822
|
+
*
|
|
2823
|
+
* {\@updoc
|
|
2824
|
+
* $ unescapeEntities('')
|
|
2825
|
+
* # ''
|
|
2826
|
+
* $ unescapeEntities('hello World!')
|
|
2827
|
+
* # 'hello World!'
|
|
2828
|
+
* $ unescapeEntities('1 < 2 && 4 > 3 ')
|
|
2829
|
+
* # '1 < 2 && 4 > 3\n'
|
|
2830
|
+
* $ unescapeEntities('<< <- unfinished entity>')
|
|
2831
|
+
* # '<< <- unfinished entity>'
|
|
2832
|
+
* $ unescapeEntities('/foo?bar=baz©=true') // & often unescaped in URLS
|
|
2833
|
+
* # '/foo?bar=baz©=true'
|
|
2834
|
+
* $ unescapeEntities('pi=ππ, Pi=Π\u03A0') // FIXME: known failure
|
|
2835
|
+
* # 'pi=\u03C0\u03c0, Pi=\u03A0\u03A0'
|
|
2836
|
+
* }
|
|
2837
|
+
*
|
|
2838
|
+
* @param {string} s a chunk of HTML CDATA. It must not start or end inside
|
|
2839
|
+
* an HTML entity.
|
|
2840
|
+
*/
|
|
2841
|
+
function unescapeEntities(s) {
|
|
2842
|
+
return s.replace(entityRe, decodeOneEntity);
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
var ampRe = /&/g;
|
|
2846
|
+
var looseAmpRe = /&([^a-z#]|#(?:[^0-9x]|x(?:[^0-9a-f]|$)|$)|$)/gi;
|
|
2847
|
+
var ltRe = /[<]/g;
|
|
2848
|
+
var gtRe = />/g;
|
|
2849
|
+
var quotRe = /\"/g;
|
|
2850
|
+
|
|
2851
|
+
/**
|
|
2852
|
+
* Escapes HTML special characters in attribute values.
|
|
2853
|
+
*
|
|
2854
|
+
* {\@updoc
|
|
2855
|
+
* $ escapeAttrib('')
|
|
2856
|
+
* # ''
|
|
2857
|
+
* $ escapeAttrib('"<<&==&>>"') // Do not just escape the first occurrence.
|
|
2858
|
+
* # '"<<&==&>>"'
|
|
2859
|
+
* $ escapeAttrib('Hello <World>!')
|
|
2860
|
+
* # 'Hello <World>!'
|
|
2861
|
+
* }
|
|
2862
|
+
*/
|
|
2863
|
+
function escapeAttrib(s) {
|
|
2864
|
+
return ('' + s).replace(ampRe, '&').replace(ltRe, '<')
|
|
2865
|
+
.replace(gtRe, '>').replace(quotRe, '"');
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
/**
|
|
2869
|
+
* Escape entities in RCDATA that can be escaped without changing the meaning.
|
|
2870
|
+
* {\@updoc
|
|
2871
|
+
* $ normalizeRCData('1 < 2 && 3 > 4 && 5 < 7&8')
|
|
2872
|
+
* # '1 < 2 && 3 > 4 && 5 < 7&8'
|
|
2873
|
+
* }
|
|
2874
|
+
*/
|
|
2875
|
+
function normalizeRCData(rcdata) {
|
|
2876
|
+
return rcdata
|
|
2877
|
+
.replace(looseAmpRe, '&$1')
|
|
2878
|
+
.replace(ltRe, '<')
|
|
2879
|
+
.replace(gtRe, '>');
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
// TODO(mikesamuel): validate sanitizer regexs against the HTML5 grammar at
|
|
2883
|
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html
|
|
2884
|
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html
|
|
2885
|
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html
|
|
2886
|
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html
|
|
2887
|
+
|
|
2888
|
+
// We initially split input so that potentially meaningful characters
|
|
2889
|
+
// like '<' and '>' are separate tokens, using a fast dumb process that
|
|
2890
|
+
// ignores quoting. Then we walk that token stream, and when we see a
|
|
2891
|
+
// '<' that's the start of a tag, we use ATTR_RE to extract tag
|
|
2892
|
+
// attributes from the next token. That token will never have a '>'
|
|
2893
|
+
// character. However, it might have an unbalanced quote character, and
|
|
2894
|
+
// when we see that, we combine additional tokens to balance the quote.
|
|
2895
|
+
|
|
2896
|
+
var ATTR_RE = new RegExp(
|
|
2897
|
+
'^\\s*' +
|
|
2898
|
+
'([a-z][a-z-]*)' + // 1 = Attribute name
|
|
2899
|
+
'(?:' + (
|
|
2900
|
+
'\\s*(=)\\s*' + // 2 = Is there a value?
|
|
2901
|
+
'(' + ( // 3 = Attribute value
|
|
2902
|
+
// TODO(felix8a): maybe use backref to match quotes
|
|
2903
|
+
'(\")[^\"]*(\"|$)' + // 4, 5 = Double-quoted string
|
|
2904
|
+
'|' +
|
|
2905
|
+
'(\')[^\']*(\'|$)' + // 6, 7 = Single-quoted string
|
|
2906
|
+
'|' +
|
|
2907
|
+
// Positive lookahead to prevent interpretation of
|
|
2908
|
+
// <foo a= b=c> as <foo a='b=c'>
|
|
2909
|
+
// TODO(felix8a): might be able to drop this case
|
|
2910
|
+
'(?=[a-z][a-z-]*\\s*=)' +
|
|
2911
|
+
'|' +
|
|
2912
|
+
// Unquoted value that isn't an attribute name
|
|
2913
|
+
// (since we didn't match the positive lookahead above)
|
|
2914
|
+
'[^\"\'\\s]*' ) +
|
|
2915
|
+
')' ) +
|
|
2916
|
+
')?',
|
|
2917
|
+
'i');
|
|
2918
|
+
|
|
2919
|
+
var ENTITY_RE = /^(#[0-9]+|#x[0-9a-f]+|\w+);/i;
|
|
2920
|
+
|
|
2921
|
+
// false on IE<=8, true on most other browsers
|
|
2922
|
+
var splitWillCapture = ('a,b'.split(/(,)/).length === 3);
|
|
2923
|
+
|
|
2924
|
+
// bitmask for tags with special parsing, like <script> and <textarea>
|
|
2925
|
+
var EFLAGS_TEXT = html4.eflags.CDATA | html4.eflags.RCDATA;
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* Given a SAX-like event handler, produce a function that feeds those
|
|
2929
|
+
* events and a parameter to the event handler.
|
|
2930
|
+
*
|
|
2931
|
+
* The event handler has the form:{@code
|
|
2932
|
+
* {
|
|
2933
|
+
* // Name is an upper-case HTML tag name. Attribs is an array of
|
|
2934
|
+
* // alternating upper-case attribute names, and attribute values. The
|
|
2935
|
+
* // attribs array is reused by the parser. Param is the value passed to
|
|
2936
|
+
* // the saxParser.
|
|
2937
|
+
* startTag: function (name, attribs, param) { ... },
|
|
2938
|
+
* endTag: function (name, param) { ... },
|
|
2939
|
+
* pcdata: function (text, param) { ... },
|
|
2940
|
+
* rcdata: function (text, param) { ... },
|
|
2941
|
+
* cdata: function (text, param) { ... },
|
|
2942
|
+
* startDoc: function (param) { ... },
|
|
2943
|
+
* endDoc: function (param) { ... }
|
|
2944
|
+
* }}
|
|
2945
|
+
*
|
|
2946
|
+
* @param {Object} handler a record containing event handlers.
|
|
2947
|
+
* @return {function(string, Object)} A function that takes a chunk of HTML
|
|
2948
|
+
* and a parameter. The parameter is passed on to the handler methods.
|
|
2949
|
+
*/
|
|
2950
|
+
function makeSaxParser(handler) {
|
|
2951
|
+
return function(htmlText, param) {
|
|
2952
|
+
return parse(htmlText, handler, param);
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
// Parsing strategy is to split input into parts that might be lexically
|
|
2957
|
+
// meaningful (every ">" becomes a separate part), and then recombine
|
|
2958
|
+
// parts if we discover they're in a different context.
|
|
2959
|
+
|
|
2960
|
+
// Note, html-sanitizer filters unknown tags here, even though they also
|
|
2961
|
+
// get filtered out by the sanitizer's handler. This is back-compat
|
|
2962
|
+
// behavior; makeSaxParser is public.
|
|
2963
|
+
|
|
2964
|
+
// TODO(felix8a): Significant performance regressions from -legacy,
|
|
2965
|
+
// tested on
|
|
2966
|
+
// Chrome 18.0
|
|
2967
|
+
// Firefox 11.0
|
|
2968
|
+
// IE 6, 7, 8, 9
|
|
2969
|
+
// Opera 11.61
|
|
2970
|
+
// Safari 5.1.3
|
|
2971
|
+
// Many of these are unusual patterns that are linearly slower and still
|
|
2972
|
+
// pretty fast (eg 1ms to 5ms), so not necessarily worth fixing.
|
|
2973
|
+
|
|
2974
|
+
// TODO(felix8a): "<script> && && && ... <\/script>" is slower on all
|
|
2975
|
+
// browsers. The hotspot is htmlSplit.
|
|
2976
|
+
|
|
2977
|
+
// TODO(felix8a): "<p title='>>>>...'><\/p>" is slower on all browsers.
|
|
2978
|
+
// This is partly htmlSplit, but the hotspot is parseTagAndAttrs.
|
|
2979
|
+
|
|
2980
|
+
// TODO(felix8a): "<a><\/a><a><\/a>..." is slower on IE9.
|
|
2981
|
+
// "<a>1<\/a><a>1<\/a>..." is faster, "<a><\/a>2<a><\/a>2..." is faster.
|
|
2982
|
+
|
|
2983
|
+
// TODO(felix8a): "<p<p<p..." is slower on IE[6-8]
|
|
2984
|
+
|
|
2985
|
+
var continuationMarker = {};
|
|
2986
|
+
function parse(htmlText, handler, param) {
|
|
2987
|
+
var h = handler;
|
|
2988
|
+
var m, p, tagName;
|
|
2989
|
+
var parts = htmlSplit(htmlText);
|
|
2990
|
+
var state = {
|
|
2991
|
+
noMoreGT: false,
|
|
2992
|
+
noMoreEndComments: false
|
|
2993
|
+
};
|
|
2994
|
+
parseCPS(handler, parts, 0, state, param);
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
function continuationMaker(h, parts, initial, state, param) {
|
|
2998
|
+
return function () {
|
|
2999
|
+
parseCPS(h, parts, initial, state, param);
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
function parseCPS(h, parts, initial, state, param) {
|
|
3004
|
+
try {
|
|
3005
|
+
if (h.startDoc && initial == 0) { h.startDoc(param); }
|
|
3006
|
+
var m, p, tagName;
|
|
3007
|
+
for (var pos = initial, end = parts.length; pos < end;) {
|
|
3008
|
+
var current = parts[pos++];
|
|
3009
|
+
var next = parts[pos];
|
|
3010
|
+
switch (current) {
|
|
3011
|
+
case '&':
|
|
3012
|
+
if (ENTITY_RE.test(next)) {
|
|
3013
|
+
if (h.pcdata) {
|
|
3014
|
+
h.pcdata('&' + next, param, continuationMarker,
|
|
3015
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3016
|
+
}
|
|
3017
|
+
pos++;
|
|
3018
|
+
} else {
|
|
3019
|
+
if (h.pcdata) { h.pcdata("&", param, continuationMarker,
|
|
3020
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
break;
|
|
3024
|
+
case '<\/':
|
|
3025
|
+
if (m = /^(\w+)[^\'\"]*/.exec(next)) {
|
|
3026
|
+
if (m[0].length === next.length && parts[pos + 1] === '>') {
|
|
3027
|
+
// fast case, no attribute parsing needed
|
|
3028
|
+
pos += 2;
|
|
3029
|
+
tagName = lcase(m[1]);
|
|
3030
|
+
if (html4.ELEMENTS.hasOwnProperty(tagName)) {
|
|
3031
|
+
if (h.endTag) {
|
|
3032
|
+
h.endTag(tagName, param, continuationMarker,
|
|
3033
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
} else {
|
|
3037
|
+
// slow case, need to parse attributes
|
|
3038
|
+
// TODO(felix8a): do we really care about misparsing this?
|
|
3039
|
+
pos = parseEndTag(
|
|
3040
|
+
parts, pos, h, param, continuationMarker, state);
|
|
3041
|
+
}
|
|
3042
|
+
} else {
|
|
3043
|
+
if (h.pcdata) {
|
|
3044
|
+
h.pcdata('</', param, continuationMarker,
|
|
3045
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
break;
|
|
3049
|
+
case '<':
|
|
3050
|
+
if (m = /^(\w+)\s*\/?/.exec(next)) {
|
|
3051
|
+
if (m[0].length === next.length && parts[pos + 1] === '>') {
|
|
3052
|
+
// fast case, no attribute parsing needed
|
|
3053
|
+
pos += 2;
|
|
3054
|
+
tagName = lcase(m[1]);
|
|
3055
|
+
if (html4.ELEMENTS.hasOwnProperty(tagName)) {
|
|
3056
|
+
if (h.startTag) {
|
|
3057
|
+
h.startTag(tagName, [], param, continuationMarker,
|
|
3058
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3059
|
+
}
|
|
3060
|
+
// tags like <script> and <textarea> have special parsing
|
|
3061
|
+
var eflags = html4.ELEMENTS[tagName];
|
|
3062
|
+
if (eflags & EFLAGS_TEXT) {
|
|
3063
|
+
var tag = { name: tagName, next: pos, eflags: eflags };
|
|
3064
|
+
pos = parseText(
|
|
3065
|
+
parts, tag, h, param, continuationMarker, state);
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
} else {
|
|
3069
|
+
// slow case, need to parse attributes
|
|
3070
|
+
pos = parseStartTag(
|
|
3071
|
+
parts, pos, h, param, continuationMarker, state);
|
|
3072
|
+
}
|
|
3073
|
+
} else {
|
|
3074
|
+
if (h.pcdata) {
|
|
3075
|
+
h.pcdata('<', param, continuationMarker,
|
|
3076
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
break;
|
|
3080
|
+
case '<\!--':
|
|
3081
|
+
// The pathological case is n copies of '<\!--' without '-->', and
|
|
3082
|
+
// repeated failure to find '-->' is quadratic. We avoid that by
|
|
3083
|
+
// remembering when search for '-->' fails.
|
|
3084
|
+
if (!state.noMoreEndComments) {
|
|
3085
|
+
// A comment <\!--x--> is split into three tokens:
|
|
3086
|
+
// '<\!--', 'x--', '>'
|
|
3087
|
+
// We want to find the next '>' token that has a preceding '--'.
|
|
3088
|
+
// pos is at the 'x--'.
|
|
3089
|
+
for (p = pos + 1; p < end; p++) {
|
|
3090
|
+
if (parts[p] === '>' && /--$/.test(parts[p - 1])) { break; }
|
|
3091
|
+
}
|
|
3092
|
+
if (p < end) {
|
|
3093
|
+
pos = p + 1;
|
|
3094
|
+
} else {
|
|
3095
|
+
state.noMoreEndComments = true;
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
if (state.noMoreEndComments) {
|
|
3099
|
+
if (h.pcdata) {
|
|
3100
|
+
h.pcdata('<!--', param, continuationMarker,
|
|
3101
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
break;
|
|
3105
|
+
case '<\!':
|
|
3106
|
+
if (!/^\w/.test(next)) {
|
|
3107
|
+
if (h.pcdata) {
|
|
3108
|
+
h.pcdata('<!', param, continuationMarker,
|
|
3109
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3110
|
+
}
|
|
3111
|
+
} else {
|
|
3112
|
+
// similar to noMoreEndComment logic
|
|
3113
|
+
if (!state.noMoreGT) {
|
|
3114
|
+
for (p = pos + 1; p < end; p++) {
|
|
3115
|
+
if (parts[p] === '>') { break; }
|
|
3116
|
+
}
|
|
3117
|
+
if (p < end) {
|
|
3118
|
+
pos = p + 1;
|
|
3119
|
+
} else {
|
|
3120
|
+
state.noMoreGT = true;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
if (state.noMoreGT) {
|
|
3124
|
+
if (h.pcdata) {
|
|
3125
|
+
h.pcdata('<!', param, continuationMarker,
|
|
3126
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
break;
|
|
3131
|
+
case '<?':
|
|
3132
|
+
// similar to noMoreEndComment logic
|
|
3133
|
+
if (!state.noMoreGT) {
|
|
3134
|
+
for (p = pos + 1; p < end; p++) {
|
|
3135
|
+
if (parts[p] === '>') { break; }
|
|
3136
|
+
}
|
|
3137
|
+
if (p < end) {
|
|
3138
|
+
pos = p + 1;
|
|
3139
|
+
} else {
|
|
3140
|
+
state.noMoreGT = true;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
if (state.noMoreGT) {
|
|
3144
|
+
if (h.pcdata) {
|
|
3145
|
+
h.pcdata('<?', param, continuationMarker,
|
|
3146
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
break;
|
|
3150
|
+
case '>':
|
|
3151
|
+
if (h.pcdata) {
|
|
3152
|
+
h.pcdata(">", param, continuationMarker,
|
|
3153
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3154
|
+
}
|
|
3155
|
+
break;
|
|
3156
|
+
case '':
|
|
3157
|
+
break;
|
|
3158
|
+
default:
|
|
3159
|
+
if (h.pcdata) {
|
|
3160
|
+
h.pcdata(current, param, continuationMarker,
|
|
3161
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3162
|
+
}
|
|
3163
|
+
break;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
if (h.endDoc) { h.endDoc(param); }
|
|
3167
|
+
} catch (e) {
|
|
3168
|
+
if (e !== continuationMarker) { throw e; }
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
// Split str into parts for the html parser.
|
|
3173
|
+
function htmlSplit(str) {
|
|
3174
|
+
// can't hoist this out of the function because of the re.exec loop.
|
|
3175
|
+
var re = /(<\/|<\!--|<[!?]|[&<>])/g;
|
|
3176
|
+
str += '';
|
|
3177
|
+
if (splitWillCapture) {
|
|
3178
|
+
return str.split(re);
|
|
3179
|
+
} else {
|
|
3180
|
+
var parts = [];
|
|
3181
|
+
var lastPos = 0;
|
|
3182
|
+
var m;
|
|
3183
|
+
while ((m = re.exec(str)) !== null) {
|
|
3184
|
+
parts.push(str.substring(lastPos, m.index));
|
|
3185
|
+
parts.push(m[0]);
|
|
3186
|
+
lastPos = m.index + m[0].length;
|
|
3187
|
+
}
|
|
3188
|
+
parts.push(str.substring(lastPos));
|
|
3189
|
+
return parts;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
function parseEndTag(parts, pos, h, param, continuationMarker, state) {
|
|
3194
|
+
var tag = parseTagAndAttrs(parts, pos);
|
|
3195
|
+
// drop unclosed tags
|
|
3196
|
+
if (!tag) { return parts.length; }
|
|
3197
|
+
if (tag.eflags !== void 0) {
|
|
3198
|
+
if (h.endTag) {
|
|
3199
|
+
h.endTag(tag.name, param, continuationMarker,
|
|
3200
|
+
continuationMaker(h, parts, pos, state, param));
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
return tag.next;
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
function parseStartTag(parts, pos, h, param, continuationMarker, state) {
|
|
3207
|
+
var tag = parseTagAndAttrs(parts, pos);
|
|
3208
|
+
// drop unclosed tags
|
|
3209
|
+
if (!tag) { return parts.length; }
|
|
3210
|
+
if (tag.eflags !== void 0) {
|
|
3211
|
+
if (h.startTag) {
|
|
3212
|
+
h.startTag(tag.name, tag.attrs, param, continuationMarker,
|
|
3213
|
+
continuationMaker(h, parts, tag.next, state, param));
|
|
3214
|
+
}
|
|
3215
|
+
// tags like <script> and <textarea> have special parsing
|
|
3216
|
+
if (tag.eflags & EFLAGS_TEXT) {
|
|
3217
|
+
return parseText(parts, tag, h, param, continuationMarker, state);
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
return tag.next;
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
var endTagRe = {};
|
|
3224
|
+
|
|
3225
|
+
// Tags like <script> and <textarea> are flagged as CDATA or RCDATA,
|
|
3226
|
+
// which means everything is text until we see the correct closing tag.
|
|
3227
|
+
function parseText(parts, tag, h, param, continuationMarker, state) {
|
|
3228
|
+
var end = parts.length;
|
|
3229
|
+
if (!endTagRe.hasOwnProperty(tag.name)) {
|
|
3230
|
+
endTagRe[tag.name] = new RegExp('^' + tag.name + '(?:[\\s\\/]|$)', 'i');
|
|
3231
|
+
}
|
|
3232
|
+
var re = endTagRe[tag.name];
|
|
3233
|
+
var first = tag.next;
|
|
3234
|
+
var p = tag.next + 1;
|
|
3235
|
+
for (; p < end; p++) {
|
|
3236
|
+
if (parts[p - 1] === '<\/' && re.test(parts[p])) { break; }
|
|
3237
|
+
}
|
|
3238
|
+
if (p < end) { p -= 1; }
|
|
3239
|
+
var buf = parts.slice(first, p).join('');
|
|
3240
|
+
if (tag.eflags & html4.eflags.CDATA) {
|
|
3241
|
+
if (h.cdata) {
|
|
3242
|
+
h.cdata(buf, param, continuationMarker,
|
|
3243
|
+
continuationMaker(h, parts, p, state, param));
|
|
3244
|
+
}
|
|
3245
|
+
} else if (tag.eflags & html4.eflags.RCDATA) {
|
|
3246
|
+
if (h.rcdata) {
|
|
3247
|
+
h.rcdata(normalizeRCData(buf), param, continuationMarker,
|
|
3248
|
+
continuationMaker(h, parts, p, state, param));
|
|
3249
|
+
}
|
|
3250
|
+
} else {
|
|
3251
|
+
throw new Error('bug');
|
|
3252
|
+
}
|
|
3253
|
+
return p;
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
// at this point, parts[pos-1] is either "<" or "<\/".
|
|
3257
|
+
function parseTagAndAttrs(parts, pos) {
|
|
3258
|
+
var m = /^(\w+)/.exec(parts[pos]);
|
|
3259
|
+
var tag = { name: lcase(m[1]) };
|
|
3260
|
+
if (html4.ELEMENTS.hasOwnProperty(tag.name)) {
|
|
3261
|
+
tag.eflags = html4.ELEMENTS[tag.name];
|
|
3262
|
+
} else {
|
|
3263
|
+
tag.eflags = void 0;
|
|
3264
|
+
}
|
|
3265
|
+
var buf = parts[pos].substr(m[0].length);
|
|
3266
|
+
// Find the next '>'. We optimistically assume this '>' is not in a
|
|
3267
|
+
// quoted context, and further down we fix things up if it turns out to
|
|
3268
|
+
// be quoted.
|
|
3269
|
+
var p = pos + 1;
|
|
3270
|
+
var end = parts.length;
|
|
3271
|
+
for (; p < end; p++) {
|
|
3272
|
+
if (parts[p] === '>') { break; }
|
|
3273
|
+
buf += parts[p];
|
|
3274
|
+
}
|
|
3275
|
+
if (end <= p) { return void 0; }
|
|
3276
|
+
var attrs = [];
|
|
3277
|
+
while (buf !== '') {
|
|
3278
|
+
m = ATTR_RE.exec(buf);
|
|
3279
|
+
if (!m) {
|
|
3280
|
+
// No attribute found: skip garbage
|
|
3281
|
+
buf = buf.replace(/^[\s\S][^a-z\s]*/, '');
|
|
3282
|
+
|
|
3283
|
+
} else if ((m[4] && !m[5]) || (m[6] && !m[7])) {
|
|
3284
|
+
// Unterminated quote: slurp to the next unquoted '>'
|
|
3285
|
+
var quote = m[4] || m[6];
|
|
3286
|
+
var sawQuote = false;
|
|
3287
|
+
var abuf = [buf, parts[p++]];
|
|
3288
|
+
for (; p < end; p++) {
|
|
3289
|
+
if (sawQuote) {
|
|
3290
|
+
if (parts[p] === '>') { break; }
|
|
3291
|
+
} else if (0 <= parts[p].indexOf(quote)) {
|
|
3292
|
+
sawQuote = true;
|
|
3293
|
+
}
|
|
3294
|
+
abuf.push(parts[p]);
|
|
3295
|
+
}
|
|
3296
|
+
// Slurp failed: lose the garbage
|
|
3297
|
+
if (end <= p) { break; }
|
|
3298
|
+
// Otherwise retry attribute parsing
|
|
3299
|
+
buf = abuf.join('');
|
|
3300
|
+
continue;
|
|
3301
|
+
|
|
3302
|
+
} else {
|
|
3303
|
+
// We have an attribute
|
|
3304
|
+
var aName = lcase(m[1]);
|
|
3305
|
+
var aValue = m[2] ? decodeValue(m[3]) : aName;
|
|
3306
|
+
attrs.push(aName, aValue);
|
|
3307
|
+
buf = buf.substr(m[0].length);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
tag.attrs = attrs;
|
|
3311
|
+
tag.next = p + 1;
|
|
3312
|
+
return tag;
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
function decodeValue(v) {
|
|
3316
|
+
var q = v.charCodeAt(0);
|
|
3317
|
+
if (q === 0x22 || q === 0x27) { // " or '
|
|
3318
|
+
v = v.substr(1, v.length - 2);
|
|
3319
|
+
}
|
|
3320
|
+
return unescapeEntities(stripNULs(v));
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
/**
|
|
3324
|
+
* Returns a function that strips unsafe tags and attributes from html.
|
|
3325
|
+
* @param {function(string, Array.<string>): ?Array.<string>} tagPolicy
|
|
3326
|
+
* A function that takes (tagName, attribs[]), where tagName is a key in
|
|
3327
|
+
* html4.ELEMENTS and attribs is an array of alternating attribute names
|
|
3328
|
+
* and values. It should return a sanitized attribute array, or null to
|
|
3329
|
+
* delete the tag. It's okay for tagPolicy to modify the attribs array,
|
|
3330
|
+
* but the same array is reused, so it should not be held between calls.
|
|
3331
|
+
* @return {function(string, Array)} A function that sanitizes a string of
|
|
3332
|
+
* HTML and appends result strings to the second argument, an array.
|
|
3333
|
+
*/
|
|
3334
|
+
function makeHtmlSanitizer(tagPolicy) {
|
|
3335
|
+
var stack;
|
|
3336
|
+
var ignoring;
|
|
3337
|
+
var emit = function (text, out) {
|
|
3338
|
+
if (!ignoring) { out.push(text); }
|
|
3339
|
+
};
|
|
3340
|
+
return makeSaxParser({
|
|
3341
|
+
startDoc: function(_) {
|
|
3342
|
+
stack = [];
|
|
3343
|
+
ignoring = false;
|
|
3344
|
+
},
|
|
3345
|
+
startTag: function(tagName, attribs, out) {
|
|
3346
|
+
if (ignoring) { return; }
|
|
3347
|
+
if (!html4.ELEMENTS.hasOwnProperty(tagName)) { return; }
|
|
3348
|
+
var eflags = html4.ELEMENTS[tagName];
|
|
3349
|
+
if (eflags & html4.eflags.FOLDABLE) {
|
|
3350
|
+
return;
|
|
3351
|
+
}
|
|
3352
|
+
attribs = tagPolicy(tagName, attribs);
|
|
3353
|
+
if (!attribs) {
|
|
3354
|
+
ignoring = !(eflags & html4.eflags.EMPTY);
|
|
3355
|
+
return;
|
|
3356
|
+
}
|
|
3357
|
+
// TODO(mikesamuel): relying on tagPolicy not to insert unsafe
|
|
3358
|
+
// attribute names.
|
|
3359
|
+
if (!(eflags & html4.eflags.EMPTY)) {
|
|
3360
|
+
stack.push(tagName);
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
out.push('<', tagName);
|
|
3364
|
+
for (var i = 0, n = attribs.length; i < n; i += 2) {
|
|
3365
|
+
var attribName = attribs[i],
|
|
3366
|
+
value = attribs[i + 1];
|
|
3367
|
+
if (value !== null && value !== void 0) {
|
|
3368
|
+
out.push(' ', attribName, '="', escapeAttrib(value), '"');
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
out.push('>');
|
|
3372
|
+
},
|
|
3373
|
+
endTag: function(tagName, out) {
|
|
3374
|
+
if (ignoring) {
|
|
3375
|
+
ignoring = false;
|
|
3376
|
+
return;
|
|
3377
|
+
}
|
|
3378
|
+
if (!html4.ELEMENTS.hasOwnProperty(tagName)) { return; }
|
|
3379
|
+
var eflags = html4.ELEMENTS[tagName];
|
|
3380
|
+
if (!(eflags & (html4.eflags.EMPTY | html4.eflags.FOLDABLE))) {
|
|
3381
|
+
var index;
|
|
3382
|
+
if (eflags & html4.eflags.OPTIONAL_ENDTAG) {
|
|
3383
|
+
for (index = stack.length; --index >= 0;) {
|
|
3384
|
+
var stackEl = stack[index];
|
|
3385
|
+
if (stackEl === tagName) { break; }
|
|
3386
|
+
if (!(html4.ELEMENTS[stackEl] &
|
|
3387
|
+
html4.eflags.OPTIONAL_ENDTAG)) {
|
|
3388
|
+
// Don't pop non optional end tags looking for a match.
|
|
3389
|
+
return;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
} else {
|
|
3393
|
+
for (index = stack.length; --index >= 0;) {
|
|
3394
|
+
if (stack[index] === tagName) { break; }
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
if (index < 0) { return; } // Not opened.
|
|
3398
|
+
for (var i = stack.length; --i > index;) {
|
|
3399
|
+
var stackEl = stack[i];
|
|
3400
|
+
if (!(html4.ELEMENTS[stackEl] &
|
|
3401
|
+
html4.eflags.OPTIONAL_ENDTAG)) {
|
|
3402
|
+
out.push('<\/', stackEl, '>');
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
stack.length = index;
|
|
3406
|
+
out.push('<\/', tagName, '>');
|
|
3407
|
+
}
|
|
3408
|
+
},
|
|
3409
|
+
pcdata: emit,
|
|
3410
|
+
rcdata: emit,
|
|
3411
|
+
cdata: emit,
|
|
3412
|
+
endDoc: function(out) {
|
|
3413
|
+
for (; stack.length; stack.length--) {
|
|
3414
|
+
out.push('<\/', stack[stack.length - 1], '>');
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
});
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
// From RFC3986
|
|
3421
|
+
var URI_SCHEME_RE = new RegExp(
|
|
3422
|
+
'^' +
|
|
3423
|
+
'(?:' +
|
|
3424
|
+
'([^:\/?# ]+)' + // scheme
|
|
3425
|
+
':)?'
|
|
3426
|
+
);
|
|
3427
|
+
|
|
3428
|
+
var ALLOWED_URI_SCHEMES = /^(?:https?|mailto)$/i;
|
|
3429
|
+
|
|
3430
|
+
function safeUri(uri, naiveUriRewriter) {
|
|
3431
|
+
if (!naiveUriRewriter) { return null; }
|
|
3432
|
+
var parsed = ('' + uri).match(URI_SCHEME_RE);
|
|
3433
|
+
if (parsed && (!parsed[1] || ALLOWED_URI_SCHEMES.test(parsed[1]))) {
|
|
3434
|
+
return naiveUriRewriter(uri);
|
|
3435
|
+
} else {
|
|
3436
|
+
return null;
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
/**
|
|
3441
|
+
* Sanitizes attributes on an HTML tag.
|
|
3442
|
+
* @param {string} tagName An HTML tag name in lowercase.
|
|
3443
|
+
* @param {Array.<?string>} attribs An array of alternating names and values.
|
|
3444
|
+
* @param {?function(?string): ?string} opt_naiveUriRewriter A transform to
|
|
3445
|
+
* apply to URI attributes; it can return a new string value, or null to
|
|
3446
|
+
* delete the attribute. If unspecified, URI attributes are deleted.
|
|
3447
|
+
* @param {function(?string): ?string} opt_nmTokenPolicy A transform to apply
|
|
3448
|
+
* to attributes containing HTML names, element IDs, and space-separated
|
|
3449
|
+
* lists of classes; it can return a new string value, or null to delete
|
|
3450
|
+
* the attribute. If unspecified, these attributes are kept unchanged.
|
|
3451
|
+
* @return {Array.<?string>} The sanitized attributes as a list of alternating
|
|
3452
|
+
* names and values, where a null value means to omit the attribute.
|
|
3453
|
+
*/
|
|
3454
|
+
function sanitizeAttribs(
|
|
3455
|
+
tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy) {
|
|
3456
|
+
for (var i = 0; i < attribs.length; i += 2) {
|
|
3457
|
+
var attribName = attribs[i];
|
|
3458
|
+
var value = attribs[i + 1];
|
|
3459
|
+
var atype = null, attribKey;
|
|
3460
|
+
if ((attribKey = tagName + '::' + attribName,
|
|
3461
|
+
html4.ATTRIBS.hasOwnProperty(attribKey)) ||
|
|
3462
|
+
(attribKey = '*::' + attribName,
|
|
3463
|
+
html4.ATTRIBS.hasOwnProperty(attribKey))) {
|
|
3464
|
+
atype = html4.ATTRIBS[attribKey];
|
|
3465
|
+
}
|
|
3466
|
+
if (atype !== null) {
|
|
3467
|
+
switch (atype) {
|
|
3468
|
+
case html4.atype.NONE: break;
|
|
3469
|
+
case html4.atype.SCRIPT:
|
|
3470
|
+
value = null;
|
|
3471
|
+
break;
|
|
3472
|
+
case html4.atype.STYLE:
|
|
3473
|
+
if ('undefined' === typeof parseCssDeclarations) {
|
|
3474
|
+
value = null;
|
|
3475
|
+
break;
|
|
3476
|
+
}
|
|
3477
|
+
var sanitizedDeclarations = [];
|
|
3478
|
+
parseCssDeclarations(
|
|
3479
|
+
value,
|
|
3480
|
+
{
|
|
3481
|
+
declaration: function (property, tokens) {
|
|
3482
|
+
var normProp = property.toLowerCase();
|
|
3483
|
+
var schema = cssSchema[normProp];
|
|
3484
|
+
if (!schema) {
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
sanitizeCssProperty(
|
|
3488
|
+
normProp, schema, tokens,
|
|
3489
|
+
opt_naiveUriRewriter);
|
|
3490
|
+
sanitizedDeclarations.push(property + ': ' + tokens.join(' '));
|
|
3491
|
+
}
|
|
3492
|
+
});
|
|
3493
|
+
value = sanitizedDeclarations.length > 0 ? sanitizedDeclarations.join(' ; ') : null;
|
|
3494
|
+
break;
|
|
3495
|
+
case html4.atype.ID:
|
|
3496
|
+
case html4.atype.IDREF:
|
|
3497
|
+
case html4.atype.IDREFS:
|
|
3498
|
+
case html4.atype.GLOBAL_NAME:
|
|
3499
|
+
case html4.atype.LOCAL_NAME:
|
|
3500
|
+
case html4.atype.CLASSES:
|
|
3501
|
+
value = opt_nmTokenPolicy ? opt_nmTokenPolicy(value) : value;
|
|
3502
|
+
break;
|
|
3503
|
+
case html4.atype.URI:
|
|
3504
|
+
value = safeUri(value, opt_naiveUriRewriter);
|
|
3505
|
+
break;
|
|
3506
|
+
case html4.atype.URI_FRAGMENT:
|
|
3507
|
+
if (value && '#' === value.charAt(0)) {
|
|
3508
|
+
value = value.substring(1); // remove the leading '#'
|
|
3509
|
+
value = opt_nmTokenPolicy ? opt_nmTokenPolicy(value) : value;
|
|
3510
|
+
if (value !== null && value !== void 0) {
|
|
3511
|
+
value = '#' + value; // restore the leading '#'
|
|
3512
|
+
}
|
|
3513
|
+
} else {
|
|
3514
|
+
value = null;
|
|
3515
|
+
}
|
|
3516
|
+
break;
|
|
3517
|
+
default:
|
|
3518
|
+
value = null;
|
|
3519
|
+
break;
|
|
3520
|
+
}
|
|
3521
|
+
} else {
|
|
3522
|
+
value = null;
|
|
3523
|
+
}
|
|
3524
|
+
attribs[i + 1] = value;
|
|
3525
|
+
}
|
|
3526
|
+
return attribs;
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
/**
|
|
3530
|
+
* Creates a tag policy that omits all tags marked UNSAFE in html4-defs.js
|
|
3531
|
+
* and applies the default attribute sanitizer with the supplied policy for
|
|
3532
|
+
* URI attributes and NMTOKEN attributes.
|
|
3533
|
+
* @param {?function(?string): ?string} opt_naiveUriRewriter A transform to
|
|
3534
|
+
* apply to URI attributes. If not given, URI attributes are deleted.
|
|
3535
|
+
* @param {function(?string): ?string} opt_nmTokenPolicy A transform to apply
|
|
3536
|
+
* to attributes containing HTML names, element IDs, and space-separated
|
|
3537
|
+
* lists of classes. If not given, such attributes are left unchanged.
|
|
3538
|
+
* @return {function(string, Array.<?string>)} A tagPolicy suitable for
|
|
3539
|
+
* passing to html.sanitize.
|
|
3540
|
+
*/
|
|
3541
|
+
function makeTagPolicy(opt_naiveUriRewriter, opt_nmTokenPolicy) {
|
|
3542
|
+
return function(tagName, attribs) {
|
|
3543
|
+
if (!(html4.ELEMENTS[tagName] & html4.eflags.UNSAFE)) {
|
|
3544
|
+
return sanitizeAttribs(
|
|
3545
|
+
tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy);
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
/**
|
|
3551
|
+
* Sanitizes HTML tags and attributes according to a given policy.
|
|
3552
|
+
* @param {string} inputHtml The HTML to sanitize.
|
|
3553
|
+
* @param {function(string, Array.<?string>)} tagPolicy A function that
|
|
3554
|
+
* decides which tags to accept and sanitizes their attributes (see
|
|
3555
|
+
* makeHtmlSanitizer above for details).
|
|
3556
|
+
* @return {string} The sanitized HTML.
|
|
3557
|
+
*/
|
|
3558
|
+
function sanitizeWithPolicy(inputHtml, tagPolicy) {
|
|
3559
|
+
var outputArray = [];
|
|
3560
|
+
makeHtmlSanitizer(tagPolicy)(inputHtml, outputArray);
|
|
3561
|
+
return outputArray.join('');
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
/**
|
|
3565
|
+
* Strips unsafe tags and attributes from HTML.
|
|
3566
|
+
* @param {string} inputHtml The HTML to sanitize.
|
|
3567
|
+
* @param {?function(?string): ?string} opt_naiveUriRewriter A transform to
|
|
3568
|
+
* apply to URI attributes. If not given, URI attributes are deleted.
|
|
3569
|
+
* @param {function(?string): ?string} opt_nmTokenPolicy A transform to apply
|
|
3570
|
+
* to attributes containing HTML names, element IDs, and space-separated
|
|
3571
|
+
* lists of classes. If not given, such attributes are left unchanged.
|
|
3572
|
+
*/
|
|
3573
|
+
function sanitize(inputHtml, opt_naiveUriRewriter, opt_nmTokenPolicy) {
|
|
3574
|
+
var tagPolicy = makeTagPolicy(opt_naiveUriRewriter, opt_nmTokenPolicy);
|
|
3575
|
+
return sanitizeWithPolicy(inputHtml, tagPolicy);
|
|
3576
|
+
}
|
|
3577
|
+
|
|
3578
|
+
return {
|
|
3579
|
+
escapeAttrib: escapeAttrib,
|
|
3580
|
+
makeHtmlSanitizer: makeHtmlSanitizer,
|
|
3581
|
+
makeSaxParser: makeSaxParser,
|
|
3582
|
+
makeTagPolicy: makeTagPolicy,
|
|
3583
|
+
normalizeRCData: normalizeRCData,
|
|
3584
|
+
sanitize: sanitize,
|
|
3585
|
+
sanitizeAttribs: sanitizeAttribs,
|
|
3586
|
+
sanitizeWithPolicy: sanitizeWithPolicy,
|
|
3587
|
+
unescapeEntities: unescapeEntities
|
|
3588
|
+
};
|
|
3589
|
+
})(html4);
|
|
3590
|
+
|
|
3591
|
+
var html_sanitize = html.sanitize;
|
|
3592
|
+
|
|
3593
|
+
// Exports for closure compiler. Note this file is also cajoled
|
|
3594
|
+
// for domado and run in an environment without 'window'
|
|
3595
|
+
if (typeof window !== 'undefined') {
|
|
3596
|
+
window['html'] = html;
|
|
3597
|
+
window['html_sanitize'] = html_sanitize;
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
}());
|