Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/*
* Copyright (c) 2020, Chris Fraire <cfraire@me.com>.
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.web;

Expand Down Expand Up @@ -67,10 +67,10 @@ public static String launderServerName(String value) {
* (non-logging) processing. The value is assumed to represent a revision string,
* not including file path.
* @return {@code null} if null or else {@code value} with anything besides
* alphanumeric or {@code :} characters removed.
* alphanumeric, {@code :}, or {@code .} characters removed.
*/
public static String launderRevision(String value) {
return replaceAll(value, "[^a-zA-Z0-9:]", "");
return replaceAll(value, "[^a-zA-Z0-9:.]", "");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/*
* Copyright (c) 2020, Chris Fraire <cfraire@me.com>.
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
*/
package org.opengrok.indexer.web;

Expand Down Expand Up @@ -70,6 +70,20 @@ void testLaunderServerName(Pair<String, String> param) {
assertEquals(param.getLeft(), Laundromat.launderServerName(param.getRight()));
}

private static Stream<Pair<String, String>> getParamsForTestLaunderRevision() {
return Stream.of(Pair.of(null, null),
Pair.of("1.2.3", "1.2.3"),
Pair.of("1:2.3", "1:2.3"),
Pair.of("abc123:.def456", "abc-123:._def/456"),
Pair.of("", "?@#/"));
}

@ParameterizedTest
@MethodSource("getParamsForTestLaunderRevision")
void testLaunderRevision(Pair<String, String> param) {
assertEquals(param.getLeft(), Laundromat.launderRevision(param.getRight()));
}

private static Stream<Pair<String, String>> getParamsForTestLaunderUriPath() {
return Stream.of(Pair.of("foo", "../../../foo"),
Pair.of("/foo/bar", "/foo/../../bar"),
Expand Down
5 changes: 3 additions & 2 deletions opengrok-web/src/main/java/org/opengrok/web/PageConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2011, Jens Elkner.
* Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2023, Gino Augustine <gino.augustine@oracle.com>.
Expand Down Expand Up @@ -715,7 +715,8 @@ public String getDefineTagsIndex() {

/**
* Get the revision parameter {@code r} from the request.
* Anything besides alphanumeric and {@code :} is removed via {@link Laundromat#launderInput(String)}.
* Anything besides alphanumeric, {@code :}, or {@code .} is removed via
* {@link Laundromat#launderRevision(String)}.
*
* @return revision if found, an empty string otherwise.
*/
Expand Down
Loading