diff --git a/src/postTools.js b/src/postTools.js index 9d4418607f..1340fd7438 100644 --- a/src/postTools.js +++ b/src/postTools.js @@ -173,7 +173,7 @@ var RDB = require('./redis.js'), var href = this.attr('href'); if (href && !href.match(domain)) { - this.attr('href', domain + 'outgoing?' + href); + this.attr('href', domain + 'outgoing?url=' + encodeURIComponent(href)); if (!isSignature) this.append(' '); } }); diff --git a/src/routes/api.js b/src/routes/api.js index 246265b1f9..b7a6719f03 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -139,10 +139,11 @@ var user = require('./../user.js'), }); app.get('/api/outgoing', function(req, res) { - var url = req.url.split('?'); - if (url[1]) { + var url = req.query.url; + + if (url) { res.json({ - url: url[1], + url: url, home: global.nconf.get('url') }); } else { diff --git a/src/webserver.js b/src/webserver.js index 70e4bee425..aa2be7a669 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -368,19 +368,15 @@ var express = require('express'), }); app.get('/outgoing', function(req, res) { - var url = req.url.split('?'); - - if (url[1]) { - app.build_header({ req: req, res: res }, function(err, header) { - res.send(header + templates['outgoing'].parse({ - url: url[1], - home: global.nconf.get('url') - }) + templates['footer']); - }); - } else { - res.status(404); - res.redirect(global.nconf.get('relative_path') + '/404'); - } + if (!req.query.url) return res.redirect('/404'); + + app.build_header({ req: req, res: res }, function(err, header) { + res.send( + header + + '\n\t' + + templates['footer'] + ); + }); }); app.get('/search', function(req, res) {