Skip to content

Commit

Permalink
Merge pull request #18244 from wangkx/h29679
Browse files Browse the repository at this point in the history
HPCC-29679 Fix isPathInPlane issue when similar prefixes

Reviewed-by: Jake Smith <[email protected]>
Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Feb 2, 2024
2 parents f8d4b22 + 4cae4a0 commit da3661d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion dali/base/dautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,28 @@ IPropertyTree * getDropZonePlane(const char * name)

bool isPathInPlane(IPropertyTree *plane, const char *path)
{
return isEmptyString(path) || startsWith(path, plane->queryProp("@prefix"));
if (isEmptyString(path))
return true;

const char *prefix = plane->queryProp("@prefix");
if (isEmptyString(prefix))
return false; //prefix is empty, path is not - can't match.

while (*prefix && *prefix == *path)
{
path++;
prefix++;
}
if (0 == *prefix)
{
if (0 == *path || isPathSepChar(*path))
return true;
if (isPathSepChar(*(path - 1))) //implies both last characters of prefix and path were '/'
return true;
}
else if (0 == *path && isPathSepChar(*prefix) && (0 == *(prefix + 1)))
return true;
return false;
}

bool validateDropZone(IPropertyTree * plane, const char * path, const char * host, bool ipMatch)
Expand Down

0 comments on commit da3661d

Please sign in to comment.