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

Explicit set utf-8 headers for file operations #157

Merged
merged 3 commits into from
Nov 12, 2023

Conversation

tschechniker
Copy link
Contributor

@tschechniker tschechniker commented Nov 11, 2023

File operations need to have utf-8 headers otherwise special allowed characters will break the file action as they will encoded to ascii per default.

Fixes #

If you have files with äöü etc. you will get an ascii encoding error cause of the reference in the Header.

This fixes this issue

Changes proposed in this pull request:

  • Set Headers to encode to UTF-8 on file operations

tschechniker and others added 2 commits November 11, 2023 19:01
File operations need to have utf-8 headers otherwise special allowed characters will break the file action as they will encoded to ascii per default.

Signed-off-by: Tobias Tschech <tobias@tschech-online.de>
@bigcat88
Copy link
Member

@tschechniker

Thanks for the pull request, and I have a question.
Can you describe a situation when the current code does not work correctly?
Which language needs to be set with which symbols in path to see the error?

I wanted to add a test for this

@tschechniker
Copy link
Contributor Author

@bigcat88

it's easy.

Scenario to reproduce:

Create a file /documents/MyTestDocumentä.doc

then try to move it with files.move to e.g. /trash/MyTestDocumentä.doc

Important here is that the destination contains the "ä" because the destination is the value added to the header field.

/document/MyTestDocumentä.doc -(move)-> /trash/MyTestDocument.doc WORKS
/document/MyTestDocument.doc -(move)-> /trash/MyTestDocumentä.doc NOT WORKING
/document/MyTestDocumentä.doc -(move)-> /trash/MyTestDocumentä.doc NOT WORKING

This also happens with all non ASCII chars which are allowed as file or folder names in nextcloud. For example äöü from german umlauts.

bigcat88 added a commit that referenced this pull request Nov 12, 2023
…158)

Probably this will fix tests from #157

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Copy link

codecov bot commented Nov 12, 2023

Codecov Report

Merging #157 (891da4c) into main (0372e78) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #157   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files          34       34           
  Lines        3134     3134           
=======================================
  Hits         3127     3127           
  Misses          7        7           
Files Coverage Δ
nc_py_api/files/files.py 99.25% <100.00%> (ø)

@bigcat88 bigcat88 merged commit 233e925 into cloud-py-api:main Nov 12, 2023
15 checks passed
@bigcat88
Copy link
Member

I will add tests for this later today(and probably will check __upload_stream as it uses the Destination header, too).
Thank you again.

bigcat88 added a commit that referenced this pull request Nov 12, 2023
The same bug that was found in: #157

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants