ServerRelativeURL not correctly encoded, leading to inability to download filenames with %
etc. in
#80
Labels
bug
Something isn't working
%
etc. in
#80
Describe the bug
If I create a file with a '%' symbol in Sharepoint, attempts to retrieve it using
GetFile
fail.I suspect it will also fail with
'
due to string concatenation being used to create API calls, and&
and other URL parameters being used due to invalid path escaping.Versions
To Reproduce
After 20% increase.docx
Expected behavior
Since the
RelativeServerURL
was returned by the API, I expected to be able to pass it to other API calls without issue.Screenshots
No screenshots.
Additional context
This seems to a problem with how
ServerRelativeURL
values are returned. For example, when callingsp.Web().GetFolder(*flagFolder).Files().Get()
the resultant JSON payload contains aServerRelativeURL
%
symbol, without it being properly URL path escaped to%25
.Within
api/web.go
there's some string formatting to create files, which looks like it is subject to the equivalent of a SQL injection, in that you can add a quote into theserverRelativeURL
and it would perhaps break?This is discussed here SharePoint/sp-dev-docs#6673 (comment)
I don't know enough about Sharepoint to know whether the return value of
ServerRelativeURL
should be URL encoded or not (maybe not), but it looks like it should be URL encoded duringGetFile
and similar calls, usingurl.PathEscape
- https://pkg.go.dev/net/url#PathEscapeA workaround is to use the
UniqueID
to access files and folders. TheUniqueID
related API calls seem to have been introduced in Sharepoint 2015.I saw #78 but it was closed, and I thought I should add a reproduction and extra context.
Thanks for your work on this library, it's very helpful!
The text was updated successfully, but these errors were encountered: