Skip to content
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

ListItemAttachments and special characters in filename #801

Closed
evlo opened this issue Feb 18, 2021 · 5 comments
Closed

ListItemAttachments and special characters in filename #801

evlo opened this issue Feb 18, 2021 · 5 comments
Labels
Good First Issue 🏆 status:fixed-next-drop Issue will be fixed in upcoming release. type:bug

Comments

@evlo
Copy link

evlo commented Feb 18, 2021

Category

[ ] Enhancement
[x] Bug
[ ] Question

Version

Please specify what version of the library you are using: [1.21.1]

Expected / Desired Behavior / Question

if you attach file with name doc'-'čííčářěášý@.docx in sharepoint online name is kept
if you attach file with name doc'-'čííčářěášý@.docx using ListItemAttachments component it gets saved as doc-.docx
if you use sharepoint REST api /_api/web/GetList(@a1)/Items(@a2)/AttachmentFiles/addUsingPath(decodedUrl=@a3)?@a1=%27%&@a2=17&@a3=%27%40%2Etxt%27 so you encode @.txt as %27%40%2Etxt%27 ie encodeURIComponent('@.txt') it works

using this.getListByRelativeUrl(this._listUrl).items.getById(itemId).attachmentFiles.addMultiple with doc%27-%27%C4%8D%C3%AD%C3%AD%C4%8D%C3%A1%C5%99%C4%9B%C3%A1%C5%A1%C3%BD%40.docx as filename fails but removing ' i'm able to save file with filename encoded as doc-%C4%8D%C3%AD%C3%AD%C4%8D%C3%A1%C5%99%C4%9B%C3%A1%C5%A1%C3%BD%40.docx at least using js

so if you escape apostrophes as %27%27 ie. doc'-'čííčářěášý@.docx becomes doc%27%27-%27%27%C4%8D%C3%AD%C3%AD%C4%8D%C3%A1%C5%99%C4%9B%C3%A1%C5%A1%C3%BD%40.docx it works in javascript/rest attachment methods

Expected / Desired Behavior
attachment is uploaded with special characters kept

Observed Behavior

special characters are removed from filename

related #526

Steps to Reproduce

upload file with name doc'-'čííčářěášý@.docx and any content

@ghost
Copy link

ghost commented Feb 18, 2021

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Feb 18, 2021
@evlo
Copy link
Author

evlo commented Mar 5, 2021

I just tried this on 2.5.0 and behavior is same as on 1.21.1

@kunj-sangani
Copy link
Contributor

kunj-sangani commented Mar 13, 2021

Hi @AJIXuMuK ,

The issue is because of the replace path in the below code
fileName.replace(/'/g, "''")

File Refernce:- SPService.ts
Method Name:- addAttachment

The replace code is present for all attachment related methods

Not sure if we can remove it or not can you please help on this

kunj-sangani added a commit to kunj-sangani/sp-dev-fx-controls-react that referenced this issue Apr 10, 2021
AJIXuMuK added a commit that referenced this issue Apr 11, 2021
#801 updated filename replacement logic
@AJIXuMuK
Copy link
Collaborator

Hi @evlo,

Could you please test the latest beta version to see if the issue is fixed for you?

@AJIXuMuK AJIXuMuK added the status:fixed-next-drop Issue will be fixed in upcoming release. label Apr 11, 2021
@joelfmrodrigues
Copy link
Collaborator

@evlo this should now be fixed in the latest version. Please update to the latest version and open a new issue if the problem persists.
Thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue 🏆 status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Projects
None yet
Development

No branches or pull requests

4 participants