auto check for base url in links

This commit is contained in:
mrdude2478 2023-09-06 06:01:19 +01:00
parent 17dcb219e5
commit 64adc685dd
12 changed files with 26 additions and 40 deletions

View File

@ -22,7 +22,6 @@ namespace inst::config {
extern bool gayMode; extern bool gayMode;
extern bool useSound; extern bool useSound;
extern bool encodeurl; extern bool encodeurl;
extern bool add_baseurl;
extern bool fixticket; extern bool fixticket;
extern bool httpkeyboard; extern bool httpkeyboard;

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "Gebe eine URL zu einer Datei ein", "hint": "Gebe eine URL zu einer Datei ein",
"invalid": "Die eingegebene URL ist ungültig", "invalid": "Die eingegebene URL ist ungültig",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " per URL" "source_string": " per URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Design verwenden", "gay_option": "Design verwenden",
"useSound": "Nutzen von Benachrichtungstönen während Installation", "useSound": "Nutzen von Benachrichtungstönen während Installation",
"encodeurl": "Auto encode urls for http server installs", "encodeurl": "Auto encode urls for http server installs",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "Signatur Patches URL: ", "sig_url": "Signatur Patches URL: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "Enter the Internet address of a file", "hint": "Enter the Internet address of a file",
"invalid": "The URL specified is invalid!", "invalid": "The URL specified is invalid!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " from URL" "source_string": " from URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Use Theme", "gay_option": "Use Theme",
"useSound": "Use sound notifications during installs", "useSound": "Use sound notifications during installs",
"encodeurl": "Auto encode urls for http server installs", "encodeurl": "Auto encode urls for http server installs",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "Signature patches source URL: ", "sig_url": "Signature patches source URL: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "Ingrese la dirección de Internet de un archivo", "hint": "Ingrese la dirección de Internet de un archivo",
"invalid": "¡La URL especificada no es válida!", "invalid": "¡La URL especificada no es válida!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": "desde la URL" "source_string": "desde la URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Usar tema", "gay_option": "Usar tema",
"useSound": "Usar notificaciones de sonido durante las instalaciones", "useSound": "Usar notificaciones de sonido durante las instalaciones",
"encodeurl": "Usar archivos php antiguos para instalaciones de servidor http", "encodeurl": "Usar archivos php antiguos para instalaciones de servidor http",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "URL de origen de parches de firma: ", "sig_url": "URL de origen de parches de firma: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "Entrez l'URL d'un fichier", "hint": "Entrez l'URL d'un fichier",
"invalid": "L'URL spécifiée n'est pas valide !", "invalid": "L'URL spécifiée n'est pas valide !",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " à partir d'un URL" "source_string": " à partir d'un URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Utiliser le thème", "gay_option": "Utiliser le thème",
"useSound": "Utiliser les notifications sonores lors des installations", "useSound": "Utiliser les notifications sonores lors des installations",
"encodeurl": "Encodage automatique des URL pour les installations de serveur http", "encodeurl": "Encodage automatique des URL pour les installations de serveur http",
"add_baseurl": "Ajout automatique de l'URL de base du serveur pour les installations de serveur http",
"fixticket": "Convertir des billets temporaires en billets permanents", "fixticket": "Convertir des billets temporaires en billets permanents",
"usehttpkeyboard": "Utiliser le clavier lors des installations du serveur http", "usehttpkeyboard": "Utiliser le clavier lors des installations du serveur http",
"sig_url": "Patchs de signatures URL: ", "sig_url": "Patchs de signatures URL: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "Inserisci l'URL del file", "hint": "Inserisci l'URL del file",
"invalid": "L'URL specificato non è valido!", "invalid": "L'URL specificato non è valido!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " da URL" "source_string": " da URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Usa tema", "gay_option": "Usa tema",
"useSound": "Use sound notifications during installs", "useSound": "Use sound notifications during installs",
"encodeurl": "Auto encode urls for http server installs", "encodeurl": "Auto encode urls for http server installs",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "Fonte URL SigPatches: ", "sig_url": "Fonte URL SigPatches: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "ファイルのインターネットアドレスを入力してください", "hint": "ファイルのインターネットアドレスを入力してください",
"invalid": "指定されたURLは無効です", "invalid": "指定されたURLは無効です",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " URLから" "source_string": " URLから"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "テーマを使用する", "gay_option": "テーマを使用する",
"useSound": "インストール時にサウンドで通知する", "useSound": "インストール時にサウンドで通知する",
"encodeurl": "Auto encode urls for http server installs", "encodeurl": "Auto encode urls for http server installs",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "署名パッチのソースURL: ", "sig_url": "署名パッチのソースURL: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "Укажите ссылку на файл", "hint": "Укажите ссылку на файл",
"invalid": "Указан неверный URL!", "invalid": "Указан неверный URL!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " из URL" "source_string": " из URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Использовать тему", "gay_option": "Использовать тему",
"useSound": "Use sound notifications during installs", "useSound": "Use sound notifications during installs",
"encodeurl": "Auto encode urls for http server installs", "encodeurl": "Auto encode urls for http server installs",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "URL для скачивания Signature patches: ", "sig_url": "URL для скачивания Signature patches: ",

View File

@ -53,6 +53,7 @@
"url": { "url": {
"hint": "請輸入檔案的URL網路位址", "hint": "請輸入檔案的URL網路位址",
"invalid": "URL網路位址無效", "invalid": "URL網路位址無效",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": "來源為URL" "source_string": "來源為URL"
}, },
"gdrive": { "gdrive": {
@ -177,7 +178,6 @@
"gay_option": "套用主題", "gay_option": "套用主題",
"useSound": "在安裝過程中使用音效提醒進度", "useSound": "在安裝過程中使用音效提醒進度",
"encodeurl": "Auto encode urls for http server installs", "encodeurl": "Auto encode urls for http server installs",
"add_baseurl": "Auto add server base url for http server installs",
"fixticket": "Convert temporary tickets to permanent", "fixticket": "Convert temporary tickets to permanent",
"usehttpkeyboard": "Use keyboard during http server installs", "usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "簽名修補程式來源URL: ", "sig_url": "簽名修補程式來源URL: ",

View File

@ -459,8 +459,10 @@ namespace netInstStuff {
if (link.find("../") == std::string::npos) if (link.find("../") == std::string::npos)
if (findCaseInsensitive(link, ".nsp") != std::string::npos || findCaseInsensitive(link, ".nsz") != std::string::npos || findCaseInsensitive(link, ".xci") != std::string::npos || findCaseInsensitive(link, ".xcz") != std::string::npos) { if (findCaseInsensitive(link, ".nsp") != std::string::npos || findCaseInsensitive(link, ".nsz") != std::string::npos || findCaseInsensitive(link, ".xci") != std::string::npos || findCaseInsensitive(link, ".xcz") != std::string::npos) {
if (inst::config::encodeurl) { if (inst::config::encodeurl) {
// if url encoded is set in options - url encode the link
link = urlencode(link); link = urlencode(link);
if (inst::config::add_baseurl) { // if the link doesn't contain http in the url add the url from the settings page
if (link.find("http") == std::string::npos) {
std::string before_strip = stripfilename(url); std::string before_strip = stripfilename(url);
urls.push_back(before_strip + "/" + link); urls.push_back(before_strip + "/" + link);
} }
@ -469,7 +471,8 @@ namespace netInstStuff {
} }
} }
else { else {
if (inst::config::add_baseurl) { // if the link doesn't contain http in the url add the url from the settings page
if (link.find("http") == std::string::npos) {
std::string before_strip = stripfilename(url); std::string before_strip = stripfilename(url);
urls.push_back(before_strip + "/" + link); urls.push_back(before_strip + "/" + link);
} }
@ -503,6 +506,10 @@ namespace netInstStuff {
return urls; return urls;
} }
else {
inst::ui::mainApp->CreateShowDialog("inst.net.url.nolinks"_lang, "", { "common.ok"_lang }, false, "romfs:/images/icons/fail.png");
}
LOG_DEBUG("Failed to parse games from HTML\n"); LOG_DEBUG("Failed to parse games from HTML\n");
} }
} }

View File

@ -156,10 +156,6 @@ namespace inst::ui {
encodeurl->SetColor(COLOR("#FFFFFFFF")); encodeurl->SetColor(COLOR("#FFFFFFFF"));
encodeurl->SetIcon(this->getMenuOptionIcon(inst::config::encodeurl)); encodeurl->SetIcon(this->getMenuOptionIcon(inst::config::encodeurl));
this->menu->AddItem(encodeurl); this->menu->AddItem(encodeurl);
auto add_baseurl = pu::ui::elm::MenuItem::New("options.menu_items.add_baseurl"_lang);
add_baseurl->SetColor(COLOR("#FFFFFFFF"));
add_baseurl->SetIcon(this->getMenuOptionIcon(inst::config::add_baseurl));
this->menu->AddItem(add_baseurl);
auto fixticket = pu::ui::elm::MenuItem::New("options.menu_items.fixticket"_lang); auto fixticket = pu::ui::elm::MenuItem::New("options.menu_items.fixticket"_lang);
fixticket->SetColor(COLOR("#FFFFFFFF")); fixticket->SetColor(COLOR("#FFFFFFFF"));
fixticket->SetIcon(this->getMenuOptionIcon(inst::config::fixticket)); fixticket->SetIcon(this->getMenuOptionIcon(inst::config::fixticket));
@ -303,18 +299,6 @@ namespace inst::ui {
break; break;
case 8: case 8:
if (inst::config::add_baseurl) {
inst::config::add_baseurl = false;
}
else {
inst::config::add_baseurl = true;
}
this->setMenuText();
this->menu->SetSelectedIndex(index);
inst::config::setConfig();
break;
case 9:
if (inst::config::fixticket) { if (inst::config::fixticket) {
inst::config::fixticket = false; inst::config::fixticket = false;
} }
@ -326,7 +310,7 @@ namespace inst::ui {
inst::config::setConfig(); inst::config::setConfig();
break; break;
case 10: case 9:
if (inst::config::httpkeyboard) { if (inst::config::httpkeyboard) {
inst::config::httpkeyboard = false; inst::config::httpkeyboard = false;
} }
@ -338,11 +322,11 @@ namespace inst::ui {
inst::config::setConfig(); inst::config::setConfig();
break; break;
case 11: case 10:
sigPatchesMenuItem_Click(); sigPatchesMenuItem_Click();
break; break;
case 12: case 11:
keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500); keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500);
if (keyboardResult.size() > 0) { if (keyboardResult.size() > 0) {
inst::config::sigPatchesUrl = keyboardResult; inst::config::sigPatchesUrl = keyboardResult;
@ -352,7 +336,7 @@ namespace inst::ui {
} }
break; break;
case 13: case 12:
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httpIndexUrl.c_str(), 500); keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httpIndexUrl.c_str(), 500);
if (keyboardResult.size() > 0) { if (keyboardResult.size() > 0) {
inst::config::httpIndexUrl = keyboardResult; inst::config::httpIndexUrl = keyboardResult;
@ -362,7 +346,7 @@ namespace inst::ui {
} }
break; break;
case 14: case 13:
languageList = languageStrings; languageList = languageStrings;
languageList.push_back("options.language.system_language"_lang); languageList.push_back("options.language.system_language"_lang);
rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false, flag ); rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false, flag );
@ -399,7 +383,7 @@ namespace inst::ui {
mainApp->FadeOut(); mainApp->FadeOut();
mainApp->Close(); mainApp->Close();
break; break;
case 15: case 14:
if (inst::util::getIPAddress() == "1.0.0.127") { if (inst::util::getIPAddress() == "1.0.0.127") {
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/update.png"); inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/update.png");
break; break;
@ -411,7 +395,7 @@ namespace inst::ui {
} }
this->askToUpdate(downloadUrl); this->askToUpdate(downloadUrl);
break; break;
case 16: case 15:
inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, { "common.close"_lang }, true, "romfs:/images/icons/credits.png"); inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, { "common.close"_lang }, true, "romfs:/images/icons/credits.png");
break; break;
default: default:

View File

@ -19,7 +19,6 @@ namespace inst::config {
bool usbAck; bool usbAck;
bool validateNCAs; bool validateNCAs;
bool encodeurl; bool encodeurl;
bool add_baseurl;
bool fixticket; bool fixticket;
bool httpkeyboard; bool httpkeyboard;
@ -38,8 +37,7 @@ namespace inst::config {
{"validateNCAs", validateNCAs}, {"validateNCAs", validateNCAs},
{"httpIndexUrl", httpIndexUrl}, {"httpIndexUrl", httpIndexUrl},
{"httplastUrl", httplastUrl}, {"httplastUrl", httplastUrl},
{"httpoldphp", encodeurl}, {"encodeurl", encodeurl},
{"add_baseurl", add_baseurl},
{"fixticket", fixticket}, {"fixticket", fixticket},
{"httpkeyboard", httpkeyboard} {"httpkeyboard", httpkeyboard}
}; };
@ -53,8 +51,7 @@ namespace inst::config {
nlohmann::json j; nlohmann::json j;
file >> j; file >> j;
autoUpdate = j["autoUpdate"].get<bool>(); autoUpdate = j["autoUpdate"].get<bool>();
encodeurl = j["httpoldphp"].get<bool>(); encodeurl = j["encodeurl"].get<bool>();
add_baseurl = j["add_baseurl"].get<bool>();
fixticket = j["fixticket"].get<bool>(); fixticket = j["fixticket"].get<bool>();
httpkeyboard = j["httpkeyboard"].get<bool>(); httpkeyboard = j["httpkeyboard"].get<bool>();
deletePrompt = j["deletePrompt"].get<bool>(); deletePrompt = j["deletePrompt"].get<bool>();
@ -82,7 +79,6 @@ namespace inst::config {
gayMode = false; gayMode = false;
useSound = true; useSound = true;
encodeurl = false; encodeurl = false;
add_baseurl = true;
fixticket = true; fixticket = true;
httpkeyboard = false; httpkeyboard = false;
ignoreReqVers = true; ignoreReqVers = true;