Skip to content

Commit a145f62

Browse files
committed
Merge branch '6.2.x'
2 parents d710f73 + 15c20c3 commit a145f62

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Diff for: spring-web/src/main/java/org/springframework/web/util/RfcUriParser.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -496,8 +496,7 @@ public void index(int index) {
496496
// Component capture
497497

498498
public InternalParser resolveIfOpaque() {
499-
boolean hasSlash = (this.uri.indexOf('/', this.index + 1) == -1);
500-
this.isOpaque = (hasSlash && !hierarchicalSchemes.contains(this.scheme));
499+
this.isOpaque = (this.uri.charAt(this.index) != '/' && !hierarchicalSchemes.contains(this.scheme));
501500
return this;
502501
}
503502

Diff for: spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -155,6 +155,19 @@ void fromOpaqueUri() {
155155
assertThat(result.toUri()).as("Invalid result URI").isEqualTo(uri);
156156
}
157157

158+
@ParameterizedTest // see gh-34588
159+
@EnumSource
160+
void fromOpaqueUriWithUrnScheme(ParserType parserType) {
161+
URI uri = UriComponentsBuilder
162+
.fromUriString("urn:text:service-{region}:{prefix}/{id}", parserType).build()
163+
.expand("US", "prefix1", "Id-2")
164+
.toUri();
165+
166+
assertThat(uri.getScheme()).isEqualTo("urn");
167+
assertThat(uri.isOpaque()).isTrue();
168+
assertThat(uri.getSchemeSpecificPart()).isEqualTo("text:service-US:prefix1/Id-2");
169+
}
170+
158171
@ParameterizedTest // see gh-9317
159172
@EnumSource
160173
void fromUriEncodedQuery(ParserType parserType) {

0 commit comments

Comments
 (0)