From 3ecaf665ae4b3ce6c33f20d3eaf93e8193de60f3 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Thu, 4 Jun 2015 16:39:27 +0200 Subject: [PATCH] Importing a subfolder of the sketchbook or importing a folder that contains the sketchbook is now blocked. Fixes #2795 --- app/src/processing/app/Base.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 8958bb4e5..89fc37b66 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2471,8 +2471,17 @@ public class Base { } } - // is there a valid library? File libFolder = sourceFile; + if (FileUtils.isSubDirectory(new File(PreferencesData.get("sketchbook.path")), libFolder)) { + activeEditor.statusError(_("A subfolder of your sketchbook is not a valid library")); + return; + } + + if (FileUtils.isSubDirectory(libFolder, new File(PreferencesData.get("sketchbook.path")))) { + activeEditor.statusError(_("You can't import a folder that contains your sketchbook")); + return; + } + String libName = libFolder.getName(); if (!BaseNoGui.isSanitaryName(libName)) { String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"