Skip to content

Commit

Permalink
KEYCLOAK-15012 Fix issue with folder theme provider
Browse files Browse the repository at this point in the history
  • Loading branch information
stianst authored and mposolda committed Nov 6, 2020
1 parent 2df6236 commit 1281f28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion services/src/main/java/org/keycloak/theme/FolderTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public InputStream getResourceAsStream(String path) throws IOException {
}

File file = new File(resourcesDir, path);
if (!file.isFile() || !file.getCanonicalPath().startsWith(resourcesDir.getCanonicalPath())) {
if (!file.isFile() || !file.getCanonicalPath().startsWith(resourcesDir.getCanonicalPath() + File.separator)) {
return null;
} else {
return file.toURI().toURL().openStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ public void close() {
}

private File getThemeDir(String name, Theme.Type type) {
return new File(themesDir, name + File.separator + type.name().toLowerCase());
File f = new File(themesDir, name + File.separator + type.name().toLowerCase());
try {
if (!f.getCanonicalPath().startsWith(themesDir.getCanonicalPath() + File.separator)) {
return null;
}
} catch (IOException e) {
return null;
}
return f;
}

}

0 comments on commit 1281f28

Please sign in to comment.