Permalink
Browse files

small change so that urls being saved do not contain javascript in it

  • Loading branch information...
jeromegv committed Sep 24, 2014
1 parent 391b797 commit 7090fbcd4c83966f29029985000a90b8aa59b39b
Showing with 6 additions and 1 deletion.
  1. +4 −0 api/archive_api.js
  2. +2 −1 api/datapoint_api.js
View
@@ -9,6 +9,8 @@ function load_archiveApi(app, websitemodel) {
app.get('/api/archiveurl/:id', function (req, res) {
return WebsiteModel.findById(req.params.id, function (err, archive) {
if (!err && archive) {
//remove javascript tag, in case it was still in the data
archive.content=archive.content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,' ');
return res.jsonp(archive);
} else {
console.log(err);
@@ -22,6 +24,8 @@ function load_archiveApi(app, websitemodel) {
var url = 'http://'+req.params.url;
return WebsiteModel.find({url: url}, function (err, archive) {
if (!err && archive) {
//remove javascript tag, in case it was still in the data
archive.content=archive.content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,' ');
return res.jsonp(archive);
} else {
console.log(err);
View
@@ -53,7 +53,8 @@ function saveUrl(url,WebsiteModel,sourceId,callback){
if (!error && typeof(response)!='undefined' && response.statusCode == 200){
website = new WebsiteModel({
url: url,
content: body
//strip out javascript script loading from the data
content: body.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,' ')
});
} else {
console.log("Can't save url:"+url+" error:"+error);

0 comments on commit 7090fbc

Please sign in to comment.