Skip to content

Commit

Permalink
Remove protocolForURL monkeypatch
Browse files Browse the repository at this point in the history
The DOM helper used to require a specially patched version of
`protocolForURL` to work in Node. This commit:

1) Adds a test to verify attributes are correctly sanitized in Node
2) Removes the monkeypatch
  • Loading branch information
tomdale committed Dec 3, 2015
1 parent 0728060 commit 75f07b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 0 additions & 6 deletions tests/node/helpers/app-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var emberPath = path.join(distPath, 'ember.debug.cjs');
var templateCompilerPath = path.join(distPath, 'ember-template-compiler');
var features = require(path.join(__dirname, '../../../features.json')).features;
var SimpleDOM = require('simple-dom');
var URL = require('url');

/*
* This helper sets up a QUnit test module with all of the environment and
Expand Down Expand Up @@ -101,11 +100,6 @@ module.exports = function(moduleName) {
// TODO: REMOVE ME

// Patch DOMHelper
Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function(url) {
var protocol = URL.parse(url).protocol;
return (protocol == null) ? ':' : protocol;
};

Ember.HTMLBars.DOMHelper.prototype.setMorphHTML = function(morph, html) {
var section = this.document.createRawHTMLSection(html);
morph.setNode(section);
Expand Down
18 changes: 18 additions & 0 deletions tests/node/visit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ QUnit.test('FastBoot: redirect', function(assert) {
]);
});

QUnit.test('FastBoot: attributes are sanitized', function(assert) {
this.template('application', '<a href={{test}}></a>');

this.controller('application', {
/*jshint scripturl:true*/
test: 'javascript:alert("hello")'
});

var App = this.createApplication();

return RSVP.all([
fastbootVisit(App, '/').then(
assertFastbootResult(assert, { url: '/', body: '<a href="unsafe:javascript:alert\\(&quot;hello&quot;\\)"></a>' }),
handleError(assert)
)
]);
});

QUnit.test('FastBoot: route error', function(assert) {
this.routes(function() {
this.route('a');
Expand Down

0 comments on commit 75f07b3

Please sign in to comment.