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

Add an Automatic Filename Normalizer (OneDrive Supported Filenames) #21

Closed
OttomanZ opened this issue Feb 7, 2023 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@OttomanZ
Copy link

OttomanZ commented Feb 7, 2023

Hi,
I use this utility quite a lot and one thing I have noticed is that sometimes there are filenames that have characters like $.|, etc that cause this to give error:400, and when I remove those characters as suggested in Microsoft Graph API Docs, it uploads without an issue.

Another Important Issue

Required Changes for Illegal Characters

  • Removing White spaces in paths as follows, ./output/ something i like.pdf will not upload due to a while space before the name something. Where as this will upload ./output/something i like.pdf.
  • Trailing white spaces also cause issues such as ./output/something i like.pdf will not upload and hence it needs to be fixed.
  • Illegal Characters need to be removed, my implementation in python
    """
    Removes Illegal OneDrive Characters
    """

    correct_name = filename.split('/')[2]
    correct_name = correct_name.lstrip()
    # removing the illegal characters
    #  ~ " # % & * : < > ? / \ { | }
    correct_name = correct_name.replace('~', '')
    correct_name = correct_name.replace('"', '')
    correct_name = correct_name.replace('#', '')
    correct_name = correct_name.replace('%', '')
    correct_name = correct_name.replace('&', '')
    correct_name = correct_name.replace('*', '')
    correct_name = correct_name.replace(':', '')
    correct_name = correct_name.replace('<', '')
    correct_name = correct_name.replace('>', '')
    correct_name = correct_name.replace('?', '')
    correct_name = correct_name.replace('/', '')
    correct_name = correct_name.replace('\\', '')
    correct_name = correct_name.replace('{', '')
    correct_name = correct_name.replace('|', '')
    correct_name = correct_name.replace('}', '')

So, I think this should be No. 1 Priority in onedrive-uploader releases from now on.

@OttomanZ
Copy link
Author

OttomanZ commented Feb 7, 2023

@virtualzone I believe this Microsoft Support Page should be referenced here for a quick implementation for filename sanitation https://support.microsoft.com/en-us/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa

@virtualzone virtualzone added the bug Something isn't working label Feb 9, 2023
@virtualzone virtualzone self-assigned this Feb 9, 2023
@virtualzone
Copy link
Owner

Hi @OttomanZ, thanks for this hint! I have implemented file and folder name sanitisation in version 0.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants