apache / apache/curator

[CURATOR-571] PathUtils.validatePath() allows \u001f (unit separator)

Open
#1,090 0 comments 0 reactions 0 assignees View on GitHub
bug imported-jira-issue
Dominant language
Java
Stars
3.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

This piece of code in PathUtils.java seems to use odd ranges for disallowed characters:



 } else if (c > '\u0000' && c < '\u001f'

|| c > '\u007f' && c < '\u009F'
|| c > '\ud800' && c < '\uf8ff'
|| c > '\ufff0' && c < '\uffff')


I can understand that 0 is disallowed by earlier condition in the code. But why is 0x1f (unit separator) allowed? Maybe the author wanted to use c<='\u001f'? Similarly, the term of the next condition allows 0x7f. And the same goes for the other two ranges.

Either I am missing something here and the ranges are somehow OK, or I am right and the ranges are wrong and should include the boundaries.

I would expect the following test to pass but they don't, except the first one:



@Test

public void testPathUtilsInCurator() {
PathUtils.validatePath("/test");
}

@Test(expected = IllegalArgumentException.class)
public void testPathUtils0x1f() {
PathUtils.validatePath("/test\u001f");
}

@Test(expected = IllegalArgumentException.class)
public void testPathUtils0x7f() {
PathUtils.validatePath("/test\u007f");
}

@Test(expected = IllegalArgumentException.class)
public void testPathUtils0xffff() {
PathUtils.validatePath("/test\uFFFF");
}



 

---
Originally reported by wilx, imported from: PathUtils.validatePath() allows \u001f (unit separator)


  • status: Open
  • priority: Major
  • resolution: Unresolved
  • imported: 2025-01-21

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.