mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
improved in case of file://// (probably)
This commit is contained in:
parent
a4887b2691
commit
bdf1b4e28b
@ -597,7 +597,6 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
return ORBIS_HTTP_ERROR_INVALID_URL;
|
return ORBIS_HTTP_ERROR_INVALID_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the output structure if provided
|
|
||||||
if (out) {
|
if (out) {
|
||||||
memset(out, 0, sizeof(OrbisHttpUriElement));
|
memset(out, 0, sizeof(OrbisHttpUriElement));
|
||||||
}
|
}
|
||||||
@ -612,12 +611,12 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
LOG_ERROR(Lib_Http, "invalid url");
|
LOG_ERROR(Lib_Http, "invalid url");
|
||||||
return ORBIS_HTTP_ERROR_INVALID_URL;
|
return ORBIS_HTTP_ERROR_INVALID_URL;
|
||||||
}
|
}
|
||||||
requiredBufferSize +=
|
requiredBufferSize += calculateComponentLength(currentPos, schemeEnd) + 1;
|
||||||
calculateComponentLength(currentPos, schemeEnd) + 1; // Include null terminator
|
|
||||||
currentPos = schemeEnd + 1;
|
currentPos = schemeEnd + 1;
|
||||||
|
|
||||||
// Check if the URI is opaque or hierarchical
|
// Check if the URI is opaque or hierarchical
|
||||||
bool isOpaque = true; // Assume opaque by default
|
bool isOpaque = true; // Assume opaque by default
|
||||||
|
bool isFile = false;
|
||||||
if (strncmp(currentPos, "//", 2) == 0) {
|
if (strncmp(currentPos, "//", 2) == 0) {
|
||||||
isOpaque = false; // Hierarchical if "//" is present
|
isOpaque = false; // Hierarchical if "//" is present
|
||||||
currentPos += 2; // Skip "//"
|
currentPos += 2; // Skip "//"
|
||||||
@ -625,6 +624,7 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
|
|
||||||
// in case it starts with file://///
|
// in case it starts with file://///
|
||||||
if (strncmp(currentPos, "//", 2) == 0) {
|
if (strncmp(currentPos, "//", 2) == 0) {
|
||||||
|
isFile = true;
|
||||||
currentPos += 2; // Skip "//"
|
currentPos += 2; // Skip "//"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,22 +637,19 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
// Check for credentials (username:password@host)
|
// Check for credentials (username:password@host)
|
||||||
char* atSymbol = strchr(currentPos, '@');
|
char* atSymbol = strchr(currentPos, '@');
|
||||||
if (atSymbol && atSymbol < hostEnd) {
|
if (atSymbol && atSymbol < hostEnd) {
|
||||||
requiredBufferSize +=
|
requiredBufferSize += calculateComponentLength(currentPos, atSymbol) + 1;
|
||||||
calculateComponentLength(currentPos, atSymbol) + 1; // Include null terminator
|
|
||||||
currentPos = atSymbol + 1;
|
currentPos = atSymbol + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for port (host:port)
|
// Check for port (host:port)
|
||||||
char* colon = strchr(currentPos, ':');
|
char* colon = strchr(currentPos, ':');
|
||||||
if (colon && colon < hostEnd) {
|
if (colon && colon < hostEnd) {
|
||||||
requiredBufferSize +=
|
requiredBufferSize += calculateComponentLength(currentPos, colon) + 1;
|
||||||
calculateComponentLength(currentPos, colon) + 1; // Include null terminator
|
|
||||||
currentPos = colon + 1;
|
currentPos = colon + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Host
|
// Host
|
||||||
requiredBufferSize +=
|
requiredBufferSize += calculateComponentLength(currentPos, hostEnd) + 1;
|
||||||
calculateComponentLength(currentPos, hostEnd) + 1; // Include null terminator
|
|
||||||
currentPos = hostEnd;
|
currentPos = hostEnd;
|
||||||
|
|
||||||
// Path (e.g., "/path")
|
// Path (e.g., "/path")
|
||||||
@ -663,8 +660,7 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
pathEnd = currentPos + strlen(currentPos);
|
pathEnd = currentPos + strlen(currentPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requiredBufferSize +=
|
requiredBufferSize += calculateComponentLength(currentPos, pathEnd) + 1;
|
||||||
calculateComponentLength(currentPos, pathEnd) + 1; // Include null terminator
|
|
||||||
currentPos = pathEnd;
|
currentPos = pathEnd;
|
||||||
|
|
||||||
// Query (e.g., "?query=value")
|
// Query (e.g., "?query=value")
|
||||||
@ -674,8 +670,7 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
if (!queryEnd) {
|
if (!queryEnd) {
|
||||||
queryEnd = currentPos + strlen(currentPos);
|
queryEnd = currentPos + strlen(currentPos);
|
||||||
}
|
}
|
||||||
requiredBufferSize +=
|
requiredBufferSize += calculateComponentLength(currentPos, queryEnd) + 1;
|
||||||
calculateComponentLength(currentPos, queryEnd) + 1; // Include null terminator
|
|
||||||
currentPos = queryEnd;
|
currentPos = queryEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,10 +678,11 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
if (*currentPos == '#') {
|
if (*currentPos == '#') {
|
||||||
currentPos++;
|
currentPos++;
|
||||||
requiredBufferSize +=
|
requiredBufferSize +=
|
||||||
calculateComponentLength(currentPos, currentPos + strlen(currentPos)) +
|
calculateComponentLength(currentPos, currentPos + strlen(currentPos)) + 1;
|
||||||
1; // Include null terminator
|
}
|
||||||
|
if (isFile) {
|
||||||
|
requiredBufferSize += 3; // if it is size needs 3 more
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the required buffer size
|
// Return the required buffer size
|
||||||
if (require) {
|
if (require) {
|
||||||
*require = requiredBufferSize;
|
*require = requiredBufferSize;
|
||||||
@ -706,7 +702,7 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
// Copy the URI components to the buffer
|
// Copy the URI components to the buffer
|
||||||
char* buffer = (char*)pool;
|
char* buffer = (char*)pool;
|
||||||
strncpy(buffer, srcUri, prepare);
|
strncpy(buffer, srcUri, prepare);
|
||||||
buffer[prepare - 1] = '\0'; // Ensure null termination
|
buffer[prepare - 1] = '\0';
|
||||||
|
|
||||||
// Parse and assign the components to the output structure if provided
|
// Parse and assign the components to the output structure if provided
|
||||||
if (out) {
|
if (out) {
|
||||||
@ -724,6 +720,10 @@ int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, v
|
|||||||
buffer += 2; // Skip "//"
|
buffer += 2; // Skip "//"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isFile) {
|
||||||
|
buffer += 2; // Skip "//"
|
||||||
|
}
|
||||||
|
|
||||||
hostEnd = strchr(buffer, '/');
|
hostEnd = strchr(buffer, '/');
|
||||||
if (!hostEnd) {
|
if (!hostEnd) {
|
||||||
hostEnd = buffer + strlen(buffer);
|
hostEnd = buffer + strlen(buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user