DATAREST-674 - Defensively handle potential double slashes in lookup

path.

We now defensively replace all double slashes contained in the lookup
path as Spring 4.2 might return such paths due to a regression in
UrlPathHelper. This might occur if the original URL contains
intermediate matrix parameters (e.g. /books/;test/1) whose removal now
results in double slashes and thus the downstream repository metadata
lookup to fail.

Related tickets: SPR-13455.
This commit is contained in:
Oliver Gierke
2015-09-10 09:17:11 +02:00
parent 25aee4be1c
commit 76380eb650
2 changed files with 12 additions and 0 deletions

View File

@@ -111,6 +111,9 @@ public class BaseUri {
Assert.notNull(lookupPath, "Lookup path must not be null!");
// Temporary fix for SPR-13455
lookupPath = lookupPath.replaceAll("//", "/");
lookupPath = trimTrailingCharacter(lookupPath, '/');
if (!baseUri.isAbsolute()) {

View File

@@ -87,4 +87,13 @@ public class BaseUriUnitTests {
assertThat(uri.getRepositoryLookupPath("/foo/people"), is("/people"));
assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people"));
}
/**
* @see DATAREST-674
* @see SPR-13455
*/
@Test
public void repositoryLookupPathHandlesDoubleSlashes() {
assertThat(BaseUri.NONE.getRepositoryLookupPath("/books//1"), is("/books/1"));
}
}