summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-10-16 18:24:23 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-10-16 18:31:02 +0000
commit2721a9f6a8a50abb8e80d1023151b16389a64201 (patch)
treea70a1e42c63f36b43f5fc349fe89ba7c01537d30 /src/extension
parentfix SVG writing with xml:space="preserve" (diff)
downloadinkscape-2721a9f6a8a50abb8e80d1023151b16389a64201.tar.gz
inkscape-2721a9f6a8a50abb8e80d1023151b16389a64201.zip
Extensions: only check existence for interpreted scripts.
This is for backwards-compatibility with older .inx files that used to redundantly request a dependency on their own interpreted script and did so with type="executable". However, in practice script files often *don't* have the x-bit set, which fortunately did not cause problems in the past, though, as the check for the x-bit was broken, see 3da7f71e45eb986aef67771b5af3c1e308971cff
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dependency.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index 69cb3199d..a9115cb86 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -147,6 +147,23 @@ bool Dependency::check ()
case TYPE_FILE: {
Glib::FileTest filetest = Glib::FILE_TEST_EXISTS;
+ std::string location(_string);
+
+ // get potential file extension for later usage
+ std::string extension;
+ size_t index = location.find_last_of(".");
+ if (index != std::string::npos) {
+ extension = location.substr(index);
+ }
+
+ // check interpreted scripts as "file" for backwards-compatibility, even if "executable" was requested
+ static const std::vector<std::string> interpreted = {".py", ".pl", ".rb"};
+ if (!extension.empty() &&
+ std::find(interpreted.begin(), interpreted.end(), extension) != interpreted.end())
+ {
+ _type = TYPE_FILE;
+ }
+
#ifndef _WIN32
// There's no executable bit on Windows, so this is unreliable
// glib would search for "executable types" instead, which are only {".exe", ".cmd", ".bat", ".com"},
@@ -156,7 +173,6 @@ bool Dependency::check ()
}
#endif
- std::string location(_string);
switch (_location) {
case LOCATION_EXTENSIONS: {
std::string temploc =
@@ -236,13 +252,6 @@ bool Dependency::check ()
// so that we don't accidentally override (or conflict with) some g_spawn_* magic.
if (_type == TYPE_EXECUTABLE) {
static const std::vector<std::string> extensions = {".exe", ".cmd", ".bat", ".com"};
-
- std::string extension;
- size_t index = final_name.find_last_of(".");
- if (index != std::string::npos) {
- extension = final_name.substr(index);
- }
-
if (extension.empty() ||
std::find(extensions.begin(), extensions.end(), extension) == extensions.end())
{