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 useSound;
extern bool encodeurl;
extern bool add_baseurl;
extern bool fixticket;
extern bool httpkeyboard;

View File

@ -53,6 +53,7 @@
"url": {
"hint": "Gebe eine URL zu einer Datei ein",
"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"
},
"gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Design verwenden",
"useSound": "Nutzen von Benachrichtungstönen während Installation",
"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",
"usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "Signatur Patches URL: ",

View File

@ -53,6 +53,7 @@
"url": {
"hint": "Enter the Internet address of a file",
"invalid": "The URL specified is invalid!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " from URL"
},
"gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Use Theme",
"useSound": "Use sound notifications during 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",
"usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "Signature patches source URL: ",

View File

@ -53,6 +53,7 @@
"url": {
"hint": "Ingrese la dirección de Internet de un archivo",
"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"
},
"gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Usar tema",
"useSound": "Usar notificaciones de sonido durante las instalaciones",
"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",
"usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "URL de origen de parches de firma: ",

View File

@ -53,6 +53,7 @@
"url": {
"hint": "Entrez l'URL d'un fichier",
"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"
},
"gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Utiliser le thème",
"useSound": "Utiliser les notifications sonores lors des installations",
"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",
"usehttpkeyboard": "Utiliser le clavier lors des installations du serveur http",
"sig_url": "Patchs de signatures URL: ",

View File

@ -53,6 +53,7 @@
"url": {
"hint": "Inserisci l'URL del file",
"invalid": "L'URL specificato non è valido!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " da URL"
},
"gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Usa tema",
"useSound": "Use sound notifications during 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",
"usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "Fonte URL SigPatches: ",

View File

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

View File

@ -53,6 +53,7 @@
"url": {
"hint": "Укажите ссылку на файл",
"invalid": "Указан неверный URL!",
"nolinks": "No XCI, XCZ, NSP, NSZ links found!\nDid you use the correct URL?",
"source_string": " из URL"
},
"gdrive": {
@ -177,7 +178,6 @@
"gay_option": "Использовать тему",
"useSound": "Use sound notifications during 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",
"usehttpkeyboard": "Use keyboard during http server installs",
"sig_url": "URL для скачивания Signature patches: ",

View File

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

View File

@ -459,8 +459,10 @@ namespace netInstStuff {
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 (inst::config::encodeurl) {
// if url encoded is set in options - url encode the 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);
urls.push_back(before_strip + "/" + link);
}
@ -469,7 +471,8 @@ namespace netInstStuff {
}
}
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);
urls.push_back(before_strip + "/" + link);
}
@ -503,6 +506,10 @@ namespace netInstStuff {
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");
}
}

View File

@ -156,10 +156,6 @@ namespace inst::ui {
encodeurl->SetColor(COLOR("#FFFFFFFF"));
encodeurl->SetIcon(this->getMenuOptionIcon(inst::config::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);
fixticket->SetColor(COLOR("#FFFFFFFF"));
fixticket->SetIcon(this->getMenuOptionIcon(inst::config::fixticket));
@ -303,18 +299,6 @@ namespace inst::ui {
break;
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) {
inst::config::fixticket = false;
}
@ -326,7 +310,7 @@ namespace inst::ui {
inst::config::setConfig();
break;
case 10:
case 9:
if (inst::config::httpkeyboard) {
inst::config::httpkeyboard = false;
}
@ -338,11 +322,11 @@ namespace inst::ui {
inst::config::setConfig();
break;
case 11:
case 10:
sigPatchesMenuItem_Click();
break;
case 12:
case 11:
keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500);
if (keyboardResult.size() > 0) {
inst::config::sigPatchesUrl = keyboardResult;
@ -352,7 +336,7 @@ namespace inst::ui {
}
break;
case 13:
case 12:
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::httpIndexUrl.c_str(), 500);
if (keyboardResult.size() > 0) {
inst::config::httpIndexUrl = keyboardResult;
@ -362,7 +346,7 @@ namespace inst::ui {
}
break;
case 14:
case 13:
languageList = languageStrings;
languageList.push_back("options.language.system_language"_lang);
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->Close();
break;
case 15:
case 14:
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");
break;
@ -411,7 +395,7 @@ namespace inst::ui {
}
this->askToUpdate(downloadUrl);
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");
break;
default:

View File

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