Add extret permissible values for Firefox.

Deprecate GET for send.
Log version number only if not supported as warning.
This commit is contained in:
burke.davey
2010-07-19 00:59:48 +00:00
parent cc99515356
commit 05ded87c1c
2 changed files with 9 additions and 6 deletions

View File

@@ -54,9 +54,11 @@ public class AuthServlet extends HttpServlet {
// side redirect instead
// Sanitize the extRet URL for XSS protection
String regEx = "chrome-extension://[a-z]+" +
String regExChrome = "chrome-extension://[a-z]+" +
(signIn ? "/signed_in\\.html" : "/signed_out\\.html");
if (extRet.matches(regEx)) {
String regExFirefox = "chrome://sendtophone" +
(signIn ? "/loggedIn" : "/loggedOut");
if (extRet.matches(regExChrome) || extRet.matches(regExFirefox)) {
resp.getWriter().println("<meta http-equiv=\"refresh\" content=\"0;url=" + extRet + "\">");
} else {
resp.setStatus(400);

View File

@@ -39,24 +39,25 @@ public class SendServlet extends HttpServlet {
private static final String DEVICE_NOT_REGISTERED_STATUS = "DEVICE_NOT_REGISTERED";
private static final String ERROR_STATUS = "ERROR";
@Deprecated
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doGet(req, resp);
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doPost(req, resp);
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
// Check API version
String apiVersionString = req.getParameter("ver");
if (apiVersionString == null) apiVersionString = "1";
int apiVersion = Integer.parseInt(apiVersionString);
log.info("Extension version: " + apiVersion);
if (apiVersion < 3) {
resp.setStatus(400);
resp.getWriter().println(ERROR_STATUS +
" (Please remove old Chrome extension and install latest)");
log.warning("Old extension version not supported: " + apiVersion);
return;
}