allow http local link to start with /

This commit is contained in:
mrdude2478 2023-09-07 10:24:01 +01:00
parent 7f52663841
commit aa7d7bed4c
3 changed files with 20 additions and 14 deletions

View File

@ -41,8 +41,8 @@ namespace Crypto
u8 headerKekSource[0x10] = { 0x1F, 0x12, 0x91, 0x3A, 0x4A, 0xCB, 0xF0, 0x0D, 0x4C, 0xDE, 0x3A, 0xF6, 0xD5, 0x23, 0x88, 0x2A };
u8 headerKeySource[0x20] = { 0x5A, 0x3E, 0xD8, 0x4F, 0xDE, 0xC0, 0xD8, 0x26, 0x31, 0xF7, 0xE2, 0x5D, 0x19, 0x7B, 0xF5, 0xD0, 0x1C, 0x9B, 0x7B, 0xFA, 0xF6, 0x28, 0x18, 0x3D, 0x71, 0xF6, 0x4D, 0x73, 0xF1, 0x50, 0xB9, 0xD2 };
//u8 headerKey[0x20] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
u8 headerKey[0x20] = { 0xAE, 0xAA, 0xB1, 0xCA, 0x08, 0xAD, 0xF9, 0xBE, 0xF1, 0x29, 0x91, 0xF3, 0x69, 0xE3, 0xC5, 0x67, 0xD6, 0x88, 0x1E, 0x4E, 0x4A, 0x6A, 0x47, 0xA5, 0x1F, 0x6E, 0x48, 0x77, 0x06, 0x2D, 0x54, 0x2D };
u8 headerKey[0x20] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//u8 headerKey[0x20] = { 0xAE, 0xAA, 0xB1, 0xCA, 0x08, 0xAD, 0xF9, 0xBE, 0xF1, 0x29, 0x91, 0xF3, 0x69, 0xE3, 0xC5, 0x67, 0xD6, 0x88, 0x1E, 0x4E, 0x4A, 0x6A, 0x47, 0xA5, 0x1F, 0x6E, 0x48, 0x77, 0x06, 0x2D, 0x54, 0x2D };
};
void calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size);

View File

@ -400,16 +400,16 @@ namespace netInstStuff {
if (!response.empty()) {
if (response[0] == '{') {
try {
nlohmann::json j = nlohmann::json::parse(response);
for (const auto& file : j["files"]) {
urls.push_back(file["url"]);
}
nlohmann::json j = nlohmann::json::parse(response);
for (const auto& file : j["files"]) {
urls.push_back(file["url"]);
}
return urls;
response.clear();
return urls;
response.clear();
}
catch (const nlohmann::detail::exception& ex) {
LOG_DEBUG("Failed to parse JSON\n");
LOG_DEBUG("Failed to parse JSON\n");
}
}
else if (!response.empty()) {
@ -431,7 +431,12 @@ namespace netInstStuff {
*/
if (link.find("http") == std::string::npos) {
std::string before_strip = stripfilename(url);
if (link[0] == '/'){
tmp_array.push_back(before_strip + link);
}
else{
tmp_array.push_back(before_strip + "/" + link);
}
}
else {
tmp_array.push_back(link);
@ -451,7 +456,7 @@ namespace netInstStuff {
debug = urlencode(decoded);
urls.push_back(debug);
}
/*
//debug for checking url before and after
FILE * fp;
@ -462,7 +467,7 @@ namespace netInstStuff {
fprintf(fp, "%s\n", info);
}
fclose(fp);
FILE * fp2;
fp2 = fopen ("after.txt", "a+");
for (unsigned long int i = 0; i < urls.size(); i++) {
@ -486,7 +491,7 @@ namespace netInstStuff {
}
response.clear();
}
else {
inst::ui::mainApp->CreateShowDialog("inst.net.index_error"_lang, "inst.net.index_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png");
break;

View File

@ -66,12 +66,13 @@ bool NcaBodyWriter::isOpen() const
//https://www.w3schools.com/cpp/cpp_classes.asp
//https://github.com/minetest/minetestmapper/blob/master/ZstdDecompressor.cpp
//https://github.com/nicoboss/nsz/blob/master/nsz/BlockDecompressorReader.py
//https://switchbrew.org/wiki/NCA
class NczHeader
{
public:
static const u64 MAGIC = 0x4E544345535A434E;
static const u64 BLOCK = 0x4E435A424C4F434B; //at 0xD0 from magic address
static const u64 MAGIC = 0x4E544345535A434E; //NTCESZCN
static const u64 BLOCK = 0x4E435A424C4F434B; //NCZBLOCK at 0x40D0
class Section
{