Browse Source

Merge pull request #15683 from ghalliday/issue26845

HPCC-26845 Fix problems with node_modules directories on windows

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 3 years ago
parent
commit
7576cd0655
4 changed files with 28 additions and 3 deletions
  1. 6 3
      ecl/hql/hqlcollect.cpp
  2. 15 0
      ecl/hql/hqlexpr.cpp
  3. 2 0
      ecl/hql/hqlexpr.hpp
  4. 5 0
      ecl/hql/hqlrepository.cpp

+ 6 - 3
ecl/hql/hqlcollect.cpp

@@ -517,9 +517,12 @@ void FileSystemDirectory::processDependencies(IDirectoryIterator * dir)
         const char * tail = pathTail(filename);
         if (file.isDirectory() == fileBool::foundYes)
         {
-            //If there is a directory within node_module, then treat that directory as a package
-            PackageDependency * depend = new PackageDependency(createIdAtom(tail), filename, false);
-            contents.append(*depend);
+            if (isValidIdentifier(tail))
+            {
+                //If there is a directory within node_module, then treat that directory as a package
+                PackageDependency * depend = new PackageDependency(createIdAtom(tail), filename, false);
+                contents.append(*depend);
+            }
         }
         else if (file.isFile() == fileBool::foundYes)
         {

+ 15 - 0
ecl/hql/hqlexpr.cpp

@@ -17204,6 +17204,21 @@ unsigned __int64 querySeqId(IHqlExpression * seq)
 #endif
 }
 
+bool isValidIdentifier(const char * text)
+{
+    if (!isalpha(*text))
+        return false;
+
+    for (;;)
+    {
+        byte next = *++text;
+        if (!next)
+            return true;
+        if (!isalnum(next) && (next != '_'))
+            return false;
+    }
+}
+
 /*
 List of changes:
 

+ 2 - 0
ecl/hql/hqlexpr.hpp

@@ -1995,4 +1995,6 @@ extern HQL_API void sanityCheckTransformation(const char * title, const HqlExprA
 extern HQL_API void sanityCheckTransformation(const char * title, IHqlExpression * before, IHqlExpression * after);
 extern HQL_API void sanityCheckTransformation(const char * title, IHqlExpression * before, const HqlExprArray & after);
 
+extern HQL_API bool isValidIdentifier(const char * text);
+
 #endif

+ 5 - 0
ecl/hql/hqlrepository.cpp

@@ -36,6 +36,11 @@ static const char * queryExtractFilename(const char * urn)
     case '/':
         return urn;
     }
+#ifdef _WIN32
+    //Check for drive:....
+    if (*urn && (urn[1] == ':'))
+        return urn;
+#endif
     return nullptr;
 }