Skip to content

Commit

Permalink
DATAREST-674 - Defensively handle potential double slashes in lookup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odrotbohm committed Sep 10, 2015
1 parent 25aee4b commit 76380eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -111,6 +111,9 @@ public String getRepositoryLookupPath(String lookupPath) {

Assert.notNull(lookupPath, "Lookup path must not be null!");

// Temporary fix for SPR-13455
lookupPath = lookupPath.replaceAll("//", "/");

lookupPath = trimTrailingCharacter(lookupPath, '/');

if (!baseUri.isAbsolute()) {
Expand Down
Expand Up @@ -87,4 +87,13 @@ public void matchesAbsoluteBaseUriOnOverlap() {
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"));
}
}

0 comments on commit 76380eb

Please sign in to comment.