|
|
@@ -48,6 +48,7 @@ import java.util.Map; |
|
|
|
import java.util.Properties; |
|
|
|
import java.util.logging.Level; |
|
|
|
import java.util.logging.Logger; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
import javax.servlet.ServletConfig; |
|
|
|
import javax.servlet.ServletContext; |
|
|
@@ -760,6 +761,13 @@ public class VaadinServlet extends HttpServlet implements Constants { |
|
|
|
*/ |
|
|
|
private static boolean scssCompileWarWarningEmitted = false; |
|
|
|
|
|
|
|
/** |
|
|
|
* Pattern for matching request paths that start with /VAADIN/, multiple |
|
|
|
* slashes allowed on either side. |
|
|
|
*/ |
|
|
|
private static Pattern staticFileRequestPathPatternVaadin = Pattern |
|
|
|
.compile("^/+VAADIN/.*"); |
|
|
|
|
|
|
|
/** |
|
|
|
* Returns the default theme. Must never return null. |
|
|
|
* |
|
|
@@ -1356,26 +1364,37 @@ public class VaadinServlet extends HttpServlet implements Constants { |
|
|
|
String decodedPath = null; |
|
|
|
String contextPath = null; |
|
|
|
try { |
|
|
|
// pathInfo should be already decoded, but some containers do not decode it, |
|
|
|
// hence we use getRequestURI instead. |
|
|
|
decodedPath = URLDecoder.decode(request.getRequestURI(), StandardCharsets.UTF_8.name()); |
|
|
|
contextPath = URLDecoder.decode(request.getContextPath(), StandardCharsets.UTF_8.name()); |
|
|
|
// pathInfo should be already decoded, but some containers do not |
|
|
|
// decode it, hence we use getRequestURI instead. |
|
|
|
decodedPath = URLDecoder.decode(request.getRequestURI(), |
|
|
|
StandardCharsets.UTF_8.name()); |
|
|
|
contextPath = URLDecoder.decode(request.getContextPath(), |
|
|
|
StandardCharsets.UTF_8.name()); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
throw new RuntimeException("An error occurred during decoding URL.",e); |
|
|
|
throw new RuntimeException("An error occurred during decoding URL.", |
|
|
|
e); |
|
|
|
} |
|
|
|
// Possible context path needs to be removed |
|
|
|
String filePath = decodedPath.substring(contextPath.length()); |
|
|
|
String servletPath = request.getServletPath(); |
|
|
|
// Possible servlet path needs to be removed |
|
|
|
if (!servletPath.isEmpty() && !servletPath.equals("/VAADIN") |
|
|
|
if (!servletPath.isEmpty() && !servletPath.equals("/VAADIN") |
|
|
|
&& filePath.startsWith(servletPath)) { |
|
|
|
filePath = filePath.substring(servletPath.length()); |
|
|
|
} |
|
|
|
// Servlet mapped as /* serves at /VAADIN |
|
|
|
// Servlet mapped as /foo/bar/* serves at /foo/bar/VAADIN |
|
|
|
if (filePath.startsWith("/VAADIN/")) { |
|
|
|
|
|
|
|
// Matches request paths /VAADIN/*, //VAADIN/* etc. |
|
|
|
if (staticFileRequestPathPatternVaadin.matcher(filePath).matches()) { |
|
|
|
// Remove any extra slashes from the beginning, |
|
|
|
// later occurrences don't interfere |
|
|
|
while (filePath.startsWith("//")) { |
|
|
|
filePath = filePath.substring(1); |
|
|
|
} |
|
|
|
return filePath; |
|
|
|
} |
|
|
|
|
|
|
|
String servletPrefixedPath = servletPath + filePath; |
|
|
|
// Servlet mapped as /VAADIN/* |
|
|
|
if (servletPrefixedPath.startsWith("/VAADIN/")) { |