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
6 changes: 3 additions & 3 deletions src/main/java/com/github/_1c_syntax/utils/Absolute.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down Expand Up @@ -136,8 +136,8 @@ private static String encodePath(@NonNull String path) {
.replace("#", "%23")
.replace("+", "%2B")
.replace(",", "%2C")
.replace("[", "%91")
.replace("]", "%93")
.replace("[", "%5B")
.replace("]", "%5D")
.replace("?", "%3F")
.replace("{", "%7B")
.replace("}", "%7D")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/_1c_syntax/utils/Lazy.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down
88 changes: 87 additions & 1 deletion src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down Expand Up @@ -250,4 +250,90 @@ void testUriObjectWithPercent() {
assertThat(uri.getPath()).contains("% ");
assertThat(uri.getPath()).endsWith(".bsl");
}

@Test
void testUriFromUriWithBrackets() {
// given
var file = new File("/git/[folder]/test[1].bsl");
var uriFromFile = file.toURI();

// when
var uri = Absolute.uri(uriFromFile);

// then
assertThat(uri).hasScheme("file");
assertThat(uri.toString()).doesNotContain("[");
assertThat(uri.toString()).doesNotContain("]");
assertThat(uri.getPath()).contains("[folder]");
assertThat(uri.getPath()).endsWith("test[1].bsl");
Comment on lines +265 to +268
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions verify that brackets are absent from the serialized URI, but they don’t explicitly validate that the encoding is the expected %5B / %5D (and not another percent sequence). Consider asserting against uri.getRawPath() (or uri.toString()) that it contains %5B and %5D (optionally also asserting it does not contain %91 / %93) to make the regression test directly cover the bug being fixed.

Copilot uses AI. Check for mistakes.
}

@Test
void testUriFromFileWithBrackets() {
// given
var file = new File("/git/[folder]/test[1].bsl");

// when
var uri = Absolute.uri(file);

// then
assertThat(uri).hasScheme("file");
assertThat(uri.toString()).doesNotContain("[");
assertThat(uri.toString()).doesNotContain("]");
assertThat(uri.getPath()).contains("[folder]");
assertThat(uri.getPath()).endsWith("test[1].bsl");
Comment on lines +281 to +284
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: this checks that [/] don’t appear in the URI string, but it doesn’t assert the actual percent-encoding used. Adding an assertion on uri.getRawPath()/uri.toString() for %5B and %5D (and/or absence of %91/%93) would make the test directly validate the intended fix.

Copilot uses AI. Check for mistakes.
}

@Test
void testPathFromStringWithBrackets() {
// given
var pathString = "/git/[folder]/test[1].bsl";

// when
var path = Absolute.path(pathString);

// then
assertThat(path.toString()).contains("[folder]");
assertThat(path.toString()).endsWith("test[1].bsl");
}

@Test
void testPathFromUriWithBrackets() {
// given
var file = new File("/git/[folder]/test[1].bsl");
var uriFromFile = file.toURI();

// when
var path = Absolute.path(uriFromFile);

// then
assertThat(path.toString()).contains("[folder]");
assertThat(path.toString()).endsWith("test[1].bsl");
}

@Test
void testPathFromPathWithBrackets() {
// given
var pathFromString = java.nio.file.Path.of("/git/[folder]/test[1].bsl");

// when
var path = Absolute.path(pathFromString);

// then
assertThat(path.toString()).contains("[folder]");
assertThat(path.toString()).endsWith("test[1].bsl");
}

@Test
void testPathFromFileWithBrackets() {
// given
var file = new File("/git/[folder]/test[1].bsl");

// when
var path = Absolute.path(file);

// then
assertThat(path.toString()).contains("[folder]");
assertThat(path.toString()).endsWith("test[1].bsl");
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is a part of 1c-syntax utils.
*
* Copyright (c) 2018-2025
* Copyright (c) 2018-2026
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
Expand Down