@@ -32,27 +32,24 @@ public void init(FilterConfig filterConfig) throws ServletException {
3232 public void doFilter (ServletRequest req , ServletResponse res , FilterChain filterChain )
3333 throws IOException , ServletException {
3434
35-
36- // If don't check referer, return.
37- if (!jsonpSwitch ) {
38- return ;
39- }
40-
4135 HttpServletRequest request = (HttpServletRequest ) req ;
4236 HttpServletResponse response = (HttpServletResponse ) res ;
4337
4438 String refer = request .getHeader ("referer" );
4539 String referWhitelist [] = {"joychou.org" , "joychou.com" };
4640
47- // Check referer for all GET requests with callback parameters.
48- if (request .getMethod ().equals ("GET" ) && StringUtils .isNotBlank (request .getParameter ("callback" )) ){
49- // If the check of referer fails, a 403 forbidden error page will be returned.
50- if (!SecurityUtil .checkURLbyEndsWith (refer , referWhitelist )){
51- response .sendRedirect ("https://test.joychou.org/error3.html" );
52- return ;
41+ if (jsonpSwitch ) {
42+ // Check referer for all GET requests with callback parameters.
43+ if (request .getMethod ().equals ("GET" ) && StringUtils .isNotBlank (request .getParameter ("callback" )) ){
44+ // If the check of referer fails, a 403 forbidden error page will be returned.
45+ if (!SecurityUtil .checkURLbyEndsWith (refer , referWhitelist )){
46+ response .sendRedirect ("https://test.joychou.org/error3.html" );
47+ return ;
48+ }
5349 }
5450 }
5551
52+
5653 filterChain .doFilter (req , res );
5754 }
5855
0 commit comments