# smarty-xss

> XSS repair or check for the smarty template.

Latest version **0.0.11** (published 2016-04-14) · 0 weekly downloads

## Install

```sh
npm install smarty-xss
pnpm add smarty-xss
yarn add smarty-xss
bun add smarty-xss
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2016-04-14 |
| First published | 2013-03-28 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | FIS Team |
| Maintainers | yuanfang, hefangshi |

## Links

- npm: https://www.npmjs.com/package/smarty-xss
- Homepage: http://fis.baidu.com/
- npm.io page: https://npm.io/package/smarty-xss

## Recent versions

- 0.0.11 (latest) — 2016-04-14
- 0.0.10 — 2014-06-05
- 0.0.9 — 2014-05-26
- 0.0.8 — 2014-05-16
- 0.0.7 — 2013-12-20
- 0.0.6 — 2013-12-19
- 0.0.5 — 2013-10-29
- 0.0.4 — 2013-09-27
- 0.0.3 — 2013-08-06
- 0.0.2 — 2013-07-11
- 0.0.1 — 2013-05-14
- 0.0.0 — 2013-03-28

## README

# XSS repair or check for the smarty template.

对Smarty模板进行XSS校验修复
======

## 安装

**npm install smarty-xss**


## 原理

通过配置对应类型(js、event、path、xml、data)的转义插件名称，对Smarty模板进行XSS检验修复。

## 使用方法

### 载入模块

```javascript
var xss = require('smarty-xss');
```

### 设置配置参数

```javascript

var option = {}
    escapeMap = {
        'js' : 'f_escape_js',
        'html' : 'f_escape_xml',
        'data' : 'f_escape_data',
        'path' : 'f_escape_path',
        'event' : 'f_escape_event',
        'no_escape' : 'escape:none'
    };
//不同类型对应的转义列表，默认为空
option['escapeMap'] = escapeMap;
//Smarty模板变量左定界符，默认为:<&
option['leftDelimiter'] = '{#';
//Smarty模板变量右定界符，默认为:&>
option['rightDelimiter'] = '#}';
//XSS安全变量，不需要进行转义
option['xssSafeVars'] = ['fis_safe','fis_xss'];
//设置参数
xss.config(option);
//只进行校验，返回为记录校验信息的数组
var check-result = xss.check('<div class="{#$spUserInfo.userName#}">{#$spUserInfo.city#}</div>');
//进行校验修复,返回为修复后的内容
var result = xss.repair('<div class="{#$spUserInfo.userName#}">{#$spUserInfo.city#}</div>');
```

## 测试

### 系统测试

在源码目录执行命令：**npm test**

---
_Source: https://npm.io/package/smarty-xss · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
