-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-30469 Avoid duplicated PathSepChar in getExternalPath() #17898
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,6 +256,16 @@ extern TPWRAPPER_API void validateDropZoneAccess(IEspContext& context, const cha | |
if (!isHostInPlane(dropZone, hostReq, true)) | ||
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Host %s is not valid DropZone plane %s", hostReq, targetDZNameOrHost); | ||
} | ||
|
||
//If the dropZonePath is an absolute path, change it to a relative path. | ||
if (isAbsolutePath(fileNameWithRelPath)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we also add some comment to CWsFileIOEx::onReadFileData in this PR (to reduce future confusion) to note that despite the "destRelativePath" saying it's relative for legacy reason, it also supports absolute paths? (I'm also curious why ReadFileDataRequest uses fields with "Dest" in them, when this is only used for reading ..) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add the comment. |
||
{ | ||
const char* relativePath = getRelativePath(fileNameWithRelPath, dropZone->queryProp("@prefix")); | ||
if (nullptr == relativePath) | ||
throw makeStringExceptionV(ECLWATCH_INVALID_INPUT, "Invalid DropZone path %s.", fileNameWithRelPath); | ||
fileNameWithRelPath = relativePath; | ||
} | ||
|
||
const char *dropZoneName = dropZone->queryProp("@name"); | ||
SecAccessFlags permission = getDZFileScopePermissions(context, dropZoneName, fileNameWithRelPath, hostReq); | ||
if (permission < permissionReq) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5642,6 +5642,24 @@ const char *splitRelativePath(const char *full,const char *basedir,StringBuffer | |
return t; | ||
} | ||
|
||
const char *getRelativePath(const char *path,const char *leadingPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note to myself - this is backported from 9.2 |
||
{ | ||
size_t pathLen = strlen(path); | ||
size_t leadingLen = strlen(leadingPath); | ||
if ((pathLen==leadingLen-1)&&isPathSepChar(leadingPath[leadingLen-1])) | ||
--leadingLen; | ||
if (0 == strncmp(path,leadingPath,leadingLen)) | ||
{ | ||
const char *rel = path + leadingLen; | ||
if ('\0' == *rel) | ||
return rel; | ||
if (isPathSepChar(*rel)) | ||
return rel+1; | ||
return rel; | ||
} | ||
return nullptr; | ||
} | ||
|
||
const char *splitDirMultiTail(const char *multipath,StringBuffer &dir,StringBuffer &tail) | ||
{ | ||
// the first directory is the significant one | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want or need to special case root, "/" is just an empty path with a trailing "/", so it will be covered by the next line afaics (comments should also change to reflect).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removeTrailingPathSepChar() only removes the "/" if dir.length() > 1:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok