Authored by 陈轩
@@ -69,8 +69,8 @@ const common = { @@ -69,8 +69,8 @@ const common = {
69 69
70 let urlObj = url.parse(refer, false, true); 70 let urlObj = url.parse(refer, false, true);
71 71
72 - if (urlObj.hostname && !/yohobuy\.com$/.test(urlObj.hostname)) {  
73 - refer = '/'; 72 + if (urlObj.hostname && !/(?:yohobuy\.com$)|(?:yoho\.cn$)/.test(urlObj.hostname)) {
  73 + refer = '/home';
74 } 74 }
75 75
76 76
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 'use strict'; 8 'use strict';
9 9
10 const _ = require('lodash'); 10 const _ = require('lodash');
  11 +const url = require('url');
11 const helpers = global.yoho.helpers; 12 const helpers = global.yoho.helpers;
12 const sign = global.yoho.sign; 13 const sign = global.yoho.sign;
13 const cookie = global.yoho.cookie; 14 const cookie = global.yoho.cookie;
@@ -61,6 +62,12 @@ let index = (req, res) => { @@ -61,6 +62,12 @@ let index = (req, res) => {
61 // req.session.REG_EXPIRE = Date.now() + 1800000; 62 // req.session.REG_EXPIRE = Date.now() + 1800000;
62 let refer = req.query.refer; 63 let refer = req.query.refer;
63 64
  65 + let urlObj = url.parse(refer, false, true);
  66 +
  67 + if (urlObj.hostname && !/(?:yohobuy\.com$)|(?:yoho\.cn$)/.test(urlObj.hostname)) {
  68 + refer = '/home';
  69 + }
  70 +
64 refer && res.cookie('refer', encodeURI(refer), { 71 refer && res.cookie('refer', encodeURI(refer), {
65 domain: 'yohobuy.com' 72 domain: 'yohobuy.com'
66 }); 73 });
@@ -402,6 +409,13 @@ let setPassword = (req, res, next) => { @@ -402,6 +409,13 @@ let setPassword = (req, res, next) => {
402 refer = '/home'; 409 refer = '/home';
403 } 410 }
404 411
  412 + // fix: http://redmine.yoho.cn/issues/14282 跳转安全
  413 + let urlObj = url.parse(refer, false, true);
  414 +
  415 + if (urlObj.hostname && !/(?:yohobuy\.com$)|(?:yoho\.cn$)/.test(urlObj.hostname)) {
  416 + refer = '/home';
  417 + }
  418 +
405 delete req.session.phoneNum; 419 delete req.session.phoneNum;
406 420
407 return res.json({ 421 return res.json({