Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Cover images fail to load after scanning because Uri.UnescapeDataString converts HTML entities like   to Unicode non-breaking space (\u00A0), which SanitizeFileName wasn't normalizing. This creates a filename mismatch between save and retrieval.

Error example:

Failed to retrieve image: /data/.../06. Lorien Testard - Lumière .jpg
                                                            ^^^^^^^^ U+00A0

Changes

  • Normalize Unicode whitespace - Added regex to convert all Unicode whitespace (including \u00A0) to regular spaces before sanitization
  • Applied consistently - Updated SanitizeFileName in CoverArtService, DeviceStaticUtils, HoarderService, and FileCoverImageProcessor
  • Added validation - Null/whitespace checks return empty string instead of potentially throwing

Before:

private static string SanitizeFileName(string fileName)
{
    return string.Join("_", fileName.Split(Path.GetInvalidFileNameChars()));
}

After:

private static string SanitizeFileName(string fileName)
{
    if (string.IsNullOrWhiteSpace(fileName))
        return string.Empty;

    var normalized = Regex.Replace(fileName, @"\s", " ").Trim();
    return string.Join("_", normalized.Split(Path.GetInvalidFileNameChars()));
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • crl.godaddy.com
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/EB23B7D1B15B85081672081E55C17E18/missingpackages_workingdir --packages /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • ocsp.godaddy.com
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/EB23B7D1B15B85081672081E55C17E18/missingpackages_workingdir --packages /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Broken Feature 📱: image loading after scan has a bug where i seem to put an extra space in the name</issue_title>
<issue_description>Can you always reproduce it?

  • Yes/No

If You Can Reproduce
Please Write down the steps from app startup till crash:
add a song and check debugger output.

Expected behavior
the image files have already been extracted and stored so the file exist checker is likely adding an extra space or so, because whenever app reboots it does load the image correctly.

The logger message is "Dimmer.Interfaces.Services.Interfaces.FileProcessing.FileProcessorUtils.CoverArtService: Error: Failed to retrieve or read image data from source: /data/user/0/com.yvanbrunel.dimmer/files/Pictures/DimmerApp/CoverImages/06. Lorien Testard - Lumière - Le Grand Café de Lumière .jpg" with an extra " .jpg" the space shiouldnt be there
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 8, 2026 11:29
- Updated SanitizeFileName in CoverArtService, DeviceStaticUtils, HoarderService, and FileCoverImageProcessor
- Added whitespace normalization to handle non-breaking spaces (U+00A0) from HTML entities like &nbsp;
- Trim leading/trailing whitespace from sanitized filenames
- Fixes issue where cover images fail to load after scanning due to filename mismatch

Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
…r method

- Removed redundant .Trim() call in HoarderService.cs (already trimmed earlier)
- Extracted inline sanitization logic to SanitizeFileName method in FileCoverImageProcessor.cs for consistency

Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix image loading issue with extra space in file name Fix cover image loading failure due to Unicode whitespace in filenames Jan 8, 2026
Copilot AI requested a review from YBTopaz8 January 8, 2026 11:38
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.

Broken Feature 📱: image loading after scan has a bug where i seem to put an extra space in the name

2 participants