mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-04-26 10:15:22 -05:00
Merge pull request #234 from rado0x54/bugfix/fix-no-itemname
Fix empty [R] name on certain webdav servers.
This commit is contained in:
commit
e1634556ca
2
Makefile
2
Makefile
|
|
@ -38,7 +38,7 @@ INCLUDES := inc inc/ui inc/fs inc/gfx
|
||||||
EXEFS_SRC := exefs_src
|
EXEFS_SRC := exefs_src
|
||||||
APP_TITLE := JKSV
|
APP_TITLE := JKSV
|
||||||
APP_AUTHOR := JK
|
APP_AUTHOR := JK
|
||||||
APP_VERSION := 07.10.2023
|
APP_VERSION := 07.25.2024
|
||||||
ROMFS := romfs
|
ROMFS := romfs
|
||||||
ICON := icon.jpg
|
ICON := icon.jpg
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
#define BLD_MON 07
|
#define BLD_MON 07
|
||||||
#define BLD_DAY 10
|
#define BLD_DAY 25
|
||||||
#define BLD_YEAR 2023
|
#define BLD_YEAR 2024
|
||||||
|
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -48,5 +48,6 @@ namespace rfs {
|
||||||
std::string getDirID(const std::string& dirName, const std::string& parentId);
|
std::string getDirID(const std::string& dirName, const std::string& parentId);
|
||||||
|
|
||||||
std::vector<RfsItem> getListWithParent(const std::string& _parent);
|
std::vector<RfsItem> getListWithParent(const std::string& _parent);
|
||||||
|
std::string getDisplayNameFromURL(const std::string &url);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,9 @@ std::vector<rfs::RfsItem> rfs::WebDav::parseXMLResponse(const std::string& xml)
|
||||||
tinyxml2::XMLElement* displaynameElem = propElem->FirstChildElement((nsPrefix + "displayname").c_str());
|
tinyxml2::XMLElement* displaynameElem = propElem->FirstChildElement((nsPrefix + "displayname").c_str());
|
||||||
if (displaynameElem) {
|
if (displaynameElem) {
|
||||||
item.name = displaynameElem->GetText();
|
item.name = displaynameElem->GetText();
|
||||||
|
} else {
|
||||||
|
// Fallback to name from href
|
||||||
|
item.name = getDisplayNameFromURL(item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
tinyxml2::XMLElement* resourcetypeElem = propElem->FirstChildElement((nsPrefix + "resourcetype").c_str());
|
tinyxml2::XMLElement* resourcetypeElem = propElem->FirstChildElement((nsPrefix + "resourcetype").c_str());
|
||||||
|
|
@ -311,3 +314,26 @@ std::vector<rfs::RfsItem> rfs::WebDav::parseXMLResponse(const std::string& xml)
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to extract and URL decode the filename from the URL
|
||||||
|
std::string rfs::WebDav::getDisplayNameFromURL(const std::string &url) {
|
||||||
|
// Find the position of the last '/'
|
||||||
|
size_t pos = url.find_last_of('/');
|
||||||
|
if (pos == std::string::npos) {
|
||||||
|
// If '/' is not found, return the whole URL as it is
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the filename from the URL
|
||||||
|
std::string encodedFilename = url.substr(pos + 1);
|
||||||
|
|
||||||
|
// URL decode the filename
|
||||||
|
int outlength;
|
||||||
|
char *decodedFilename = curl_easy_unescape(curl, encodedFilename.c_str(), encodedFilename.length(), &outlength);
|
||||||
|
std::string result(decodedFilename, outlength);
|
||||||
|
|
||||||
|
// Free the memory allocated by curl_easy_unescape
|
||||||
|
curl_free(decodedFilename);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user