Skip to content

Commit 7b892fe

Browse files
committed
Fix Vaadin Request Cache ___url_parameter
1 parent 7c837fa commit 7b892fe

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.0.1
2+
* Vaadin
3+
* Fix ``SecureVaadinRequestCache`` ignoring non-optional url parameters
4+
15
# 1.0.0
26
_Initial production ready release_
37

vaadin/src/main/java/software/xdev/sse/vaadin/SecureVaadinRequestCache.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,27 @@ protected synchronized void initAllowedPaths()
154154
.stream()
155155
.map(RouteBaseData::getTemplate)
156156
.filter(s -> !s.isBlank())
157-
.map(s -> s.replace("/:___url_parameter?", "/*"))
157+
.map(s -> {
158+
final String urlParamIdentifier = "/:___url_parameter";
159+
final int urlParamIndex = s.indexOf(urlParamIdentifier);
160+
if(urlParamIndex == -1)
161+
{
162+
return s;
163+
}
164+
165+
final String substring = s.substring(0, urlParamIndex);
166+
return substring + "/*"
167+
// Do a full level wildcard if there is more stuff (excluding the optional ?)
168+
// behind the path-part
169+
+ (s.length() - substring.length() - urlParamIdentifier.length() <= 1 ? "" : "*");
170+
})
158171
.map(s -> "/" + s)
159172
.collect(Collectors.toSet());
160173

161174
LOG.debug("Allowed paths: {}", allowedPaths);
162175

163176
this.pathMaxLength = allowedPaths.stream()
164-
.mapToInt(s -> s.length() + (s.endsWith("/*") ? this.defaultWildcardPathLengthAssumption : 0))
177+
.mapToInt(s -> s.length() + (s.endsWith("*") ? this.defaultWildcardPathLengthAssumption : 0))
165178
.max()
166179
.orElse(this.defaultPathMaxLength);
167180

0 commit comments

Comments
 (0)