Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jgraph/drawio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benson <david@draw.io>2022-05-15 13:13:37 +0300
committerGitHub <noreply@github.com>2022-05-15 13:13:37 +0300
commit01ccb271d34258872b859c0fc1d253cc81341917 (patch)
tree69d85fa7f726be71a196081a9b62289830bc36a6
parentcf5c78aa0f3127fb10053db55b39f3017a0654ae (diff)
Limit wellknown servlet to serve single file
-rw-r--r--src/main/java/com/mxgraph/online/WellKnownServlet.java50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/main/java/com/mxgraph/online/WellKnownServlet.java b/src/main/java/com/mxgraph/online/WellKnownServlet.java
index be0f0f25..c702cecf 100644
--- a/src/main/java/com/mxgraph/online/WellKnownServlet.java
+++ b/src/main/java/com/mxgraph/online/WellKnownServlet.java
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
- * Servlet to fake a .well-known directory
+ * Servlet to fake a .well-known directory, GAE does not directly support . prefixed directories
*/
@SuppressWarnings("serial")
public class WellKnownServlet extends HttpServlet
@@ -38,31 +38,41 @@ public class WellKnownServlet extends HttpServlet
{
// GAE can't serve dot prefixed folders
String uri = request.getRequestURI().replace("/.", "/");
-
- if (uri.toLowerCase().contains(".json"))
- {
- response.setContentType("application/json");
- }
-
- // Serve whatever was requested from .well-known
- try (InputStream in = getServletContext().getResourceAsStream(uri))
+
+ // Currently, there is only one file that this servlet serves. This is only
+ // needed if you want OneDrive integration.
+ if (uri != null && uri.equals("/well-known/microsoft-identity-association.json"))
{
- if (in == null)
+ if (uri.toLowerCase().contains(".json"))
{
- response.sendError(404);
- return;
+ response.setContentType("application/json");
}
-
- byte[] buffer = new byte[8192];
- int count;
- while ((count = in.read(buffer)) > 0)
+ // Serve whatever was requested from .well-known
+ try (InputStream in = getServletContext().getResourceAsStream(uri))
{
- response.getOutputStream().write(buffer, 0, count);
+ if (in == null)
+ {
+ response.sendError(404);
+ return;
+ }
+
+ byte[] buffer = new byte[8192];
+ int count;
+
+ while ((count = in.read(buffer)) > 0)
+ {
+ response.getOutputStream().write(buffer, 0, count);
+ }
+
+ response.getOutputStream().flush();
+ response.getOutputStream().close();
}
-
- response.getOutputStream().flush();
- response.getOutputStream().close();
+ }
+ else
+ {
+ response.sendError(404);
+ return;
}
}
}