eclipse-ee4j / eclipse-ee4j/jersey

FilesScanner Tokenizer does not work well with input containing delimiter characters

Open
#3,006 4 comments 0 reactions 0 assignees View on GitHub
Component: core Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

this.files = new File[Tokenizer.tokenize(fileNames, Tokenizer.COMMON_DELIMITERS).length];
for (int i = 0; i < files.length; i++)

{ files[i] = new File(fileNames[i]); }

This code has multiple problems:

* The result of Tokenizer.tokenize is not used, only the length is taken. For the input "someFile;anotherFile", this leads to a ArrayIndexOutOfBoundsException, because the files-Array has size 2, but only fileNames[0] can be read, which won't even resolve to a file, because it has not been split.
* COMMON_DELIMITERS contains the space character, which can easily be contained in a single file name. On Windows, this is quite common with "C:\Program Files\...".
#### Environment
Windows 7, Java 8
#### Affected Versions
[2.13, 2.14]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.