mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
replace utils.escape with html-escape
This commit is contained in:
parent
a94278abd1
commit
f433b7c7cf
|
|
@ -2,6 +2,7 @@
|
|||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var escapeHtml = require('escape-html');
|
||||
var http = require('http')
|
||||
, path = require('path')
|
||||
, connect = require('connect')
|
||||
|
|
@ -744,7 +745,7 @@ res.redirect = function(url){
|
|||
},
|
||||
|
||||
html: function(){
|
||||
var u = utils.escape(url);
|
||||
var u = escapeHtml(url);
|
||||
body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>';
|
||||
},
|
||||
|
||||
|
|
|
|||
16
lib/utils.js
16
lib/utils.js
|
|
@ -322,22 +322,6 @@ function acceptParams(str, index) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape special characters in the given string of html.
|
||||
*
|
||||
* @param {String} html
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.escape = function(html) {
|
||||
return String(html)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize the given path string,
|
||||
* returning a regular expression.
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
"buffer-crc32": "0.2.1",
|
||||
"connect": "2.18.0",
|
||||
"commander": "1.3.2",
|
||||
"escape-html": "1.0.1",
|
||||
"methods": "1.0.1",
|
||||
"mkdirp": "0.5.0",
|
||||
"parseurl": "1.0.1",
|
||||
|
|
|
|||
|
|
@ -94,13 +94,6 @@ describe('utils.flatten(arr)', function(){
|
|||
})
|
||||
})
|
||||
|
||||
describe('utils.escape(html)', function(){
|
||||
it('should escape html entities', function(){
|
||||
utils.escape('<script>foo & "bar"')
|
||||
.should.equal('<script>foo & "bar"')
|
||||
})
|
||||
})
|
||||
|
||||
describe('utils.parseParams(str)', function(){
|
||||
it('should default quality to 1', function(){
|
||||
utils.parseParams('text/html')
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user