Skip to content

Commit

Permalink
Merge pull request #14 from Esri/update-dependencies
Browse files Browse the repository at this point in the history
fix missing xss namespace declaration.
  • Loading branch information
ssylvia authored Sep 24, 2018
2 parents 45f5882 + 3b00820 commit dbd7c7d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Load as script tag
<script src="path/to/arcgis-html-sanitizer.min.js"></script>

<!-- CDN (Adjust the version as needed) -->
<script src="https://cdn.jsdelivr.net/npm/@esri/arcgis-html-sanitizer@0.6.0/dist/umd/arcgis-html-sanitizer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@esri/arcgis-html-sanitizer@0.7.0/dist/umd/arcgis-html-sanitizer.min.js"></script>
```

#### Basic Usage
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@esri/arcgis-html-sanitizer",
"version": "0.6.0",
"version": "0.7.0",
"description": "A simple utility to sanitize a string according to ArcGIS supported HTML specification.",
"main": "dist/node/index.js",
"repository": "https://github.com/Esri/arcgis-html-sanitizer.git",
Expand All @@ -11,7 +11,7 @@
"author": "Esri",
"license": "Apache-2.0",
"scripts": {
"build": "yarn run build:node && yarn run build:esm && yarn run build:umd",
"build": "rimraf dist && yarn run build:node && yarn run build:esm && yarn run build:umd",
"build:esm": "tsc --module ESNext --outDir ./dist/esm --declaration",
"build:node": "tsc --module commonjs --outDir ./dist/node --declaration",
"build:umd": "webpack --mode development && webpack --mode production",
Expand Down Expand Up @@ -48,13 +48,14 @@
]
},
"dependencies": {
"@types/lodash.isplainobject": "^4.0.4",
"lodash.isplainobject": "^4.0.6",
"xss": "^1.0.3"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/lodash.isplainobject": "^4.0.4",
"jest": "^23.6.0",
"rimraf": "^2.6.2",
"ts-jest": "^23.10.1",
"ts-loader": "^5.2.0",
"tslint": "^5.11.0",
Expand Down
82 changes: 41 additions & 41 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* Copyright (c) JS Foundation and other contributors <https://js.foundation/>
* MIT License, see https://raw.githubusercontent.com/lodash/lodash/4.17.10-npm/LICENSE for details
* */
import isPlainObject from 'lodash.isplainobject';
import xss from 'xss';
import isPlainObject from "lodash.isplainobject";
import xss from "xss";

/**
* The response from the validate method
Expand All @@ -34,46 +34,46 @@ export interface IValidationResponse {
export class Sanitizer {
// Supported HTML Spec: https://doc.arcgis.com/en/arcgis-online/reference/supported-html.htm
public readonly arcgisWhiteList: XSS.IWhiteList = {
a: ['href', 'target', 'style'],
img: ['src', 'width', 'height', 'border', 'alt', 'style'],
a: ["href", "target", "style"],
img: ["src", "width", "height", "border", "alt", "style"],
video: [
'autoplay',
'controls',
'height',
'loop',
'muted',
'poster',
'preload',
'src',
'width'
"autoplay",
"controls",
"height",
"loop",
"muted",
"poster",
"preload",
"src",
"width"
],
audio: ['autoplay', 'controls', 'loop', 'muted', 'preload', 'src'],
span: ['style'],
table: ['width', 'height', 'cellpadding', 'cellspacing', 'border', 'style'],
div: ['style', 'class'],
font: ['size', 'color', 'style'],
tr: ['height', 'valign', 'align', 'style'],
audio: ["autoplay", "controls", "loop", "muted", "preload", "src"],
span: ["style"],
table: ["width", "height", "cellpadding", "cellspacing", "border", "style"],
div: ["style", "class"],
font: ["size", "color", "style"],
tr: ["height", "valign", "align", "style"],
td: [
'height',
'width',
'valign',
'align',
'colspan',
'rowspan',
'nowrap',
'style'
"height",
"width",
"valign",
"align",
"colspan",
"rowspan",
"nowrap",
"style"
],
th: [
'height',
'width',
'valign',
'align',
'colspan',
'rowspan',
'nowrap',
'style'
"height",
"width",
"valign",
"align",
"colspan",
"rowspan",
"nowrap",
"style"
],
p: ['style'],
p: ["style"],
b: [],
strong: [],
i: [],
Expand All @@ -99,7 +99,7 @@ export class Sanitizer {
// Extend the defaults
xssFilterOptions = Object.create(this.arcgisFilterOptions);
Object.keys(filterOptions).forEach(key => {
if (key === 'whiteList') {
if (key === "whiteList") {
// Extend the whitelist by concatenating arrays
xssFilterOptions.whiteList = this._extendObjectOfArrays([
this.arcgisWhiteList,
Expand Down Expand Up @@ -132,16 +132,16 @@ export class Sanitizer {
*/
public sanitize(value: any): any {
switch (typeof value) {
case 'number':
case "number":
if (isNaN(value) || !isFinite(value)) {
return null;
}
return value;
case 'boolean':
case "boolean":
return value;
case 'string':
case "string":
return this._xssFilter.process(value);
case 'object':
case "object":
return this._iterateOverObject(value);
default:
return null;
Expand Down
9 changes: 3 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"esModuleInterop": true
"esModuleInterop": true,
"types": ["xss", "lodash.isplainobject", "jest"]
},
"exclude": ["node_modules", "./src/**/*.test.ts"],
"include": [
"./node_modules/@types",
"./node_modules/xss/typings",
"./src/**/*.ts"
]
"include": ["./src/**/*.ts"]
}

0 comments on commit dbd7c7d

Please sign in to comment.