Skip to content

Improvement: Handling Invalid OS Characters and Trailing Spaces in Patreon Data #293

Description

@ponta143

Description of the Issue
Patreon sometimes provides creator names or post titles that contain invalid operating system (OS) characters (e.g., ? due to multibyte character encoding issues) or trailing spaces (e.g., CreatorName).
When attempting to download these posts, the application crashes with a DirectoryNotFoundException because the operating system (OS) rejects the path and fails to create the temporary file.

Error Log (Snippet): Plaintext

Error while downloading ... Inner Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users...\download\haku89\157181848_media_656503333_QQ截?20260503004731.png.dwnldtmp'.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile()
at System.IO.Strategies.OSFileStreamStrategy.ctor()
at System.IO.FileStream.ctor()

Root cause: Since the invalid data originates from Patreon, UniversalDownloaderPlatform.DefaultImplementations.WebDownloader (WebDownloader.cs) currently tries to use this raw data directly. The DownloadFileInternal method does not sanitize the path argument before constructing the temporary file path, which leads to the crash.

Proposed solution: It would be great if the downloader could sanitize these paths before saving. I fixed this locally by introducing a SanitizeName method and applying it to both the directory parts and the file name at the beginning of the DownloadFileInternal method (right after the "Warn: path is not being checked to be a valid path here" comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions