Skip to content

Commit ed9e05e

Browse files
committed
URL-encode spaces as %20 in picon HTTP request URLs
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)
1 parent 30efd53 commit ed9e05e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/enigma2/Channels.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ int Channels::LoadChannelsExtraData(const std::shared_ptr<enigma2::data::Channel
345345
{
346346
std::string connectionURL = m_settings->GetConnectionURL();
347347
connectionURL = connectionURL.substr(0, connectionURL.size() - 1);
348-
channel->SetIconPath(StringUtils::Format("%s%s", connectionURL.c_str(), jsonChannel["picon"].get<std::string>().c_str()));
348+
std::string piconPath = jsonChannel["picon"].get<std::string>();
349+
StringUtils::Replace(piconPath, " ", "%20");
350+
channel->SetIconPath(StringUtils::Format("%s%s", connectionURL.c_str(), piconPath.c_str()));
349351

350352
Logger::Log(LEVEL_DEBUG, "%s For Channel %s, using OpenWebPiconPath: %s", __func__, jsonChannel["servicename"].get<std::string>().c_str(), channel->GetIconPath().c_str());
351353
}

src/enigma2/data/Channel.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ std::string Channel::CreateIconPath(const std::string& commonServiceReference)
181181
std::replace(iconPath.begin(), iconPath.end(), ':', '_');
182182

183183
if (m_settings->UseOnlinePicons())
184-
iconPath = StringUtils::Format("%spicon/%s.png", m_settings->GetConnectionURL().c_str(), iconPath.c_str());
184+
{
185+
std::string encodedPath = iconPath;
186+
StringUtils::Replace(encodedPath, " ", "%20");
187+
iconPath = StringUtils::Format("%spicon/%s.png", m_settings->GetConnectionURL().c_str(), encodedPath.c_str());
188+
}
185189
else
186190
iconPath = m_settings->GetIconPath().c_str() + iconPath + ".png";
187191

0 commit comments

Comments
 (0)