mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-22 09:41:51 +00:00
Add extret permissible values for Firefox.
Deprecate GET for send. Log version number only if not supported as warning.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user