Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor library to support ES201* JavaScript #206

Merged
merged 26 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6fda6e6
Add .vscode to .gitignore.
tdeekens Mar 18, 2017
5e79162
Add .babelrc to configure browser targets.
tdeekens Mar 18, 2017
74fd49f
Add webpack config files for targets.
tdeekens Mar 18, 2017
c7b7262
Refactor package.json run scripts to integrate.
tdeekens Mar 18, 2017
bba4427
Fix libary name for umd build.
tdeekens Mar 18, 2017
66284c5
Change jsdom tests to consume built version.
tdeekens Mar 18, 2017
c32c9b0
Remove jshint add xo (eslint) to support ES201*.
tdeekens Mar 18, 2017
6737ca0
Fix usage of hasOwnProperty to use Object.prototype.
tdeekens Mar 18, 2017
91de880
Add window and document as globals to eslint.
tdeekens Mar 18, 2017
7c44b8f
Fix amend-build.sh to respect new sourcemap file name.
tdeekens Mar 18, 2017
3a10258
Add prettier and move eslint config
tdeekens May 14, 2017
214d7e4
Refactor to ES201* syntax and fix UMD reliance.
tdeekens Mar 18, 2017
c860fb9
Rename creation of DOMPurity in test
tdeekens May 15, 2017
49c5132
Add npm scripts section to readme
tdeekens May 17, 2017
4f4c1ef
Fix remaining lint issues from upstream/master
tdeekens May 17, 2017
ad40343
Replace webpack with rollup for building
tdeekens May 19, 2017
03c94b5
Remove minification script
tdeekens May 19, 2017
ac54b50
Add reading version field dynamically
tdeekens May 19, 2017
dc91c9c
Update demos to consume dist build
tdeekens May 19, 2017
e38f702
Update deps and karma tests to run on rollup
tdeekens May 19, 2017
7683fc9
Update travis install deps via yarn
tdeekens May 19, 2017
f81068e
Refactor run scripts and env configuration
tdeekens May 20, 2017
98b4a7e
Add building in parallel
tdeekens May 20, 2017
7be94e1
Add distribution files
tdeekens May 20, 2017
415a4eb
Rename amend build script for clarity
tdeekens May 20, 2017
c33daff
Fix reference to webpack in readme
tdeekens May 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
["env", {
"targets": {
"chrome": 22,
"ie": 8,
"firefox": 15,
"opera": 31,
"safari": 8,
"edge": 13
},
"modules": false
}]
]
}
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
bower_components
npm-debug.log
.vscode
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sudo: false
language: node_js
cache: yarn
script: npm run test:ci
notifications:
email: false
Expand Down
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[![NPM](https://nodei.co/npm/dompurify.png)](https://nodei.co/npm/dompurify/)

DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.

It's also very simple to use and get started with.

DOMPurify is written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Edge, Firefox and Chrome - as well as almost anything else using Blink or WebKit). It doesn't break on IE6 or other legacy browsers. It either uses [a fall-back](#what-about-older-browsers-like-msie8) or simply does nothing.
DOMPurify is written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Edge, Firefox and Chrome - as well as almost anything else using Blink or WebKit). It doesn't break on IE6 or other legacy browsers. It either uses [a fall-back](#what-about-older-browsers-like-msie8) or simply does nothing.

Our automated tests cover [16 different browsers](https://github.com/cure53/DOMPurify/blob/master/test/karma.conf.js#L185) right now. We also cover Node.js v4.0.0, v5.0.0 and v6.0.0, running DOMPurify on [jsdom](https://github.com/tmpvar/jsdom).

Expand Down Expand Up @@ -203,6 +203,23 @@ You can further run local tests by executing `npm test`. The tests work fine wit

All relevant commits will be signed with the key `0x24BB6BF4` for additional security (since 8th of April 2016).

### Development and contributing

We rely on npm-run-scripts for integrating with out tooling infrastructure. We use ESLint as a pre-commit hook to ensure code consistency. Morover, to ease formatting we use [prettier](https://github.com/prettier/prettier) while building the `/dist` assets happens through `rollup`.

These are our npm scripts

- `npm test` to run our test suite via jsdom and karma
- `test:jsdom` to only run tests through jsdom
- `test:karma` to only run tests through karma
- `npm run lint` to lint the sources using ESLint (via xo)
- `npm run format` to format our sources using prettier to ease to pass ESLint
- `npm run build` to build our distribution assets minified and unminified as a UMD module
- `npm run build:umd` to only build an unminified UMD module
- `npm run build:umd:min` to only build a minified UMD module

There are more npm scripts but they are mainly to integrate with CI or are meant to be "private" for instance to amend build distribution files with every commit.

## Security Mailing List

We maintain a mailing list that notifies whenever a security-critical release of DOMPurify was published. This means, if someone found a bypass and we fixed it with a release (which always happens when a bypass was found) a mail will go out to that list. This usually happens within minutes or few hours after learning about a bypass. The list can be subscribed to here:
Expand All @@ -213,13 +230,13 @@ Feature releases will not be announced to this list.

## Who contributed?

Several people need to be listed here!
Several people need to be listed here!

[@garethheyes](https://twitter.com/garethheyes) and [@filedescriptor](https://twitter.com/filedescriptor) for invaluable help, [@shafigullin](https://twitter.com/shafigullin) for breaking the library multiple times and thereby strengthening it, [@mmrupp](https://twitter.com/mmrupp) and [@irsdl](https://twitter.com/irsdl) for doing the same.

Big thanks also go to [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro) and [@fhemberger](https://twitter.com/fhemberger)!
Big thanks also go to [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro) and [@fhemberger](https://twitter.com/fhemberger)!

Further, thanks [@neilj](https://twitter.com/neilj) and [@0xsobky](https://twitter.com/0xsobky) for their code reviews and countless small optimizations, fixes and beautifications.
Further, thanks [@neilj](https://twitter.com/neilj) and [@0xsobky](https://twitter.com/0xsobky) for their code reviews and countless small optimizations, fixes and beautifications.

Big thanks also go to [@tdeekens](https://twitter.com/tdeekens) for doing all the hard work and getting us on track with Travis CI and BrowserStack. And thanks to [@Joris-van-der-Wel](https://github.com/Joris-van-der-Wel) for setting up DOMPurify for jsdom and creating the additional test suite.

Expand Down
2 changes: 1 addition & 1 deletion demos/advanced-config-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/basic-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/config-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-link-proxy-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-mentaljs-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
<!-- Grab the latest version of MentalJS -->
<script src="./lib/Mental.js"></script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-proxy-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-removal-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-sanitize-css-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-scheme-whitelist.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-svg-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
2 changes: 1 addition & 1 deletion demos/hooks-target-blank-demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script src="../src/purify.js"></script>
<script src="../dist/purify.js"></script>
</head>
<body>
<!-- Our DIV to receive content -->
Expand Down
Loading