Skip to content

Commit 3ecaf66

Browse files
author
Federico Fissore
committed
Importing a subfolder of the sketchbook or importing a folder that contains the sketchbook is now blocked. Fixes arduino#2795
1 parent 5875909 commit 3ecaf66

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/src/processing/app/Base.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2471,8 +2471,17 @@ public void handleAddLibrary() {
24712471
}
24722472
}
24732473

2474-
// is there a valid library?
24752474
File libFolder = sourceFile;
2475+
if (FileUtils.isSubDirectory(new File(PreferencesData.get("sketchbook.path")), libFolder)) {
2476+
activeEditor.statusError(_("A subfolder of your sketchbook is not a valid library"));
2477+
return;
2478+
}
2479+
2480+
if (FileUtils.isSubDirectory(libFolder, new File(PreferencesData.get("sketchbook.path")))) {
2481+
activeEditor.statusError(_("You can't import a folder that contains your sketchbook"));
2482+
return;
2483+
}
2484+
24762485
String libName = libFolder.getName();
24772486
if (!BaseNoGui.isSanitaryName(libName)) {
24782487
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"

0 commit comments

Comments
 (0)