Check sanitaryName only on basename without extension

This regression originates from:

8725bb1e Clean up sketch loading

before this commit the sketch name sanitization was made on the sketch
name without the extension.
After 8725bb1e instead the name sanitization is made on the filename, so
including the ".ino" extension.

This lead to a weird corner case, caused by the limit of 63 characters
on the sketch name: before 8725bb1e it would be possible to save a sketch
with a name of exactly 63 characters, but after 8725bb1e this sketch will
suddenly becomes invalid becuase the 63 chars name + extension would exceed
the 63 characters limit.

This commit fix this regression.

Fix #5431
This commit is contained in:
Cristian Maglie 2016-10-03 17:00:04 +02:00
parent bc5c9b8b7e
commit 653a05273d
1 changed files with 1 additions and 1 deletions

View File

@ -106,7 +106,7 @@ public class Sketch {
private List<SketchFile> listSketchFiles(boolean showWarnings) throws IOException {
Set<SketchFile> result = new TreeSet<>(CODE_DOCS_COMPARATOR);
for (File file : FileUtils.listFiles(folder, false, EXTENSIONS)) {
if (BaseNoGui.isSanitaryName(file.getName())) {
if (BaseNoGui.isSanitaryName(FileUtils.splitFilename(file).basename)) {
result.add(new SketchFile(this, file));
} else if (showWarnings) {
System.err.println(I18n.format(tr("File name {0} is invalid: ignored"), file.getName()));