Skip to content

URL-encode spaces as %20 in picon HTTP request URLs#497

Merged
phunkyfish merged 1 commit into
kodi-pvr:Piersfrom
mapi68:Piers
May 8, 2026
Merged

URL-encode spaces as %20 in picon HTTP request URLs#497
phunkyfish merged 1 commit into
kodi-pvr:Piersfrom
mapi68:Piers

Conversation

@mapi68
Copy link
Copy Markdown
Contributor

@mapi68 mapi68 commented Apr 25, 2026

Summary

Fix picon HTTP requests failing with 400 Bad Request when channel names contain spaces.

Closes #496

Problem

When fetching picons from the web interface, the addon constructs HTTP URLs using the raw picon path without URL-encoding spaces. Web servers reject these malformed URLs with a 400 Bad Request error, leaving all channels with spaces in their name without an icon.

This affects both code paths:

  • Channel::CreateIconPath() — used when Use OpenWebIf picon path is disabled
  • Channels::LoadChannelsExtraData() — used when Use OpenWebIf picon path is enabled

Fix

URL-encode spaces as %20 before constructing the picon URL in both code paths.

src/enigma2/data/Channel.cpp

  if (m_settings->UseOnlinePicons())
-   iconPath = StringUtils::Format("%spicon/%s.png", m_settings->GetConnectionURL().c_str(), iconPath.c_str());
+  {
+    std::string encodedPath = iconPath;
+    StringUtils::Replace(encodedPath, " ", "%20");
+    iconPath = StringUtils::Format("%spicon/%s.png", m_settings->GetConnectionURL().c_str(), encodedPath.c_str());
+  }
  else
    iconPath = m_settings->GetIconPath().c_str() + iconPath + ".png";

src/enigma2/Channels.cpp

  std::string connectionURL = m_settings->GetConnectionURL();
  connectionURL = connectionURL.substr(0, connectionURL.size() - 1);
- channel->SetIconPath(StringUtils::Format("%s%s", connectionURL.c_str(), jsonChannel["picon"].get<std::string>().c_str()));
+ std::string piconPath = jsonChannel["picon"].get<std::string>();
+ StringUtils::Replace(piconPath, " ", "%20");
+ channel->SetIconPath(StringUtils::Format("%s%s", connectionURL.c_str(), piconPath.c_str()));

@phunkyfish
Copy link
Copy Markdown
Member

This is great, thanks for the contribution. If you like it released, please add a commit with the micro version number incremented in addon.xml.in and add a changelog entry.

When fetching picons from the web interface, channel names containing
spaces were used as-is in the HTTP URL, causing 400 Bad Request errors.

URL-encode spaces as %20 in both code paths:
- Channel::CreateIconPath() (UseOnlinePicons without OpenWebIf path)
- Channels::LoadChannelsExtraData() (UseOpenWebIfPiconPath)

- Bump version to 22.3.6 and add changelog entry
@phunkyfish phunkyfish merged commit 82115a4 into kodi-pvr:Piers May 8, 2026
8 checks passed
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.

Picon HTTP requests with spaces in channel names are not URL-encoded, causing 400 Bad Request errors

2 participants