"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zxingorg/src/main/java/com/google/zxing/web/HTTPSFilter.java" between
zxing-zxing-3.4.0.tar.gz and zxing-zxing-3.4.1.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.

HTTPSFilter.java  (zxing-zxing-3.4.0):HTTPSFilter.java  (zxing-zxing-3.4.1)
skipping to change at line 26 skipping to change at line 26
package com.google.zxing.web; package com.google.zxing.web;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter; import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Pattern;
/** /**
* Redirects things to HTTPS, like the main decode page, which should prefer HTT PS. * Redirects things to HTTPS, like the main decode page, which should prefer HTT PS.
*/ */
@WebFilter("/w/decode.jspx") @WebFilter("/w/decode.jspx")
public final class HTTPSFilter extends AbstractFilter { public final class HTTPSFilter extends AbstractFilter {
private static final Pattern HTTP_REGEX = Pattern.compile("http://");
@Override @Override
public void doFilter(ServletRequest servletRequest, public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
if (servletRequest.isSecure()) { if (servletRequest.isSecure()) {
chain.doFilter(servletRequest, servletResponse); chain.doFilter(servletRequest, servletResponse);
} else { } else {
HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletRequest request = (HttpServletRequest) servletRequest;
String target = request.getRequestURL().toString().replaceFirst("http://", String url = request.getRequestURL().toString();
"https://"); String target = HTTP_REGEX.matcher(url).replaceFirst("https://");
redirect(servletResponse, target); redirect(servletResponse, target);
} }
} }
} }
 End of changes. 3 change blocks. 
2 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)