From b326752b24ec4f0a572735e0eadd9087158a310b Mon Sep 17 00:00:00 2001 From: M4RKUS28 Date: Tue, 3 Oct 2023 22:21:18 +0200 Subject: [PATCH] v6.3.0: Fix problems with special characters, e.g. ' --- src/logger.h | 5 -- src/pageManager.cpp | 99 +++++++++++++++++++++++++++++++++++++++- src/pageManager.h | 42 ++--------------- src/parameterManager.cpp | 5 ++ src/parameterManager.h | 18 ++------ src/programManager.cpp | 16 +++---- src/programManager.h | 4 +- 7 files changed, 119 insertions(+), 70 deletions(-) diff --git a/src/logger.h b/src/logger.h index 936ba4e..af8f1c1 100644 --- a/src/logger.h +++ b/src/logger.h @@ -2,17 +2,12 @@ #define LOGGER_H - #include #include #include #include #include // std::time, localtime ... - -#include "parameterManager.h" - - class Logger { public: diff --git a/src/pageManager.cpp b/src/pageManager.cpp index a4b94b6..5b218df 100644 --- a/src/pageManager.cpp +++ b/src/pageManager.cpp @@ -1,6 +1,22 @@ #include "pageManager.h" + + +#ifdef _WIN32 +#include "./../include/curl/curl.h" +#include + +//----------------------????????????????? +#define noSLLCheck + +#else +#include "curl/curl.h" +#endif + + + + std::string PageManager::torAnmeldeNamen = "no-name"; bool PageManager::cloudflare_protec = false; std::mutex PageManager::torAnmeldeNamenMutex; @@ -454,11 +470,16 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, //für automatisch erste Seite aktiv ist, dann wähl aus, sonst manuel auswahl int count = 0; - std::string name = replace(Name, " ", "-"); + std::string name = replace(replace(Name, "\n", ""), " ", "-"); std::string pagesonExist; std::string correct_name = name; PAGE Page; + + //entferne sonderzeichen + replaceSZ(name, true); + name = replace(name, "--", "-"); + //für jede Seite for ( unsigned i = 0; i < pages.size(); i++ ) { @@ -495,6 +516,7 @@ checkNameRply PageManager::checkName(std::vector &pages, std::string Name, if(pos1 != std::string::npos && pos2 != std::string::npos) { correct_name = tryGetGoodName.substr(pos1 + 6, pos2 - pos1 - 6); } + replaceSZ(correct_name); } if(useFirstPage) { @@ -734,6 +756,56 @@ int PageManager::compareVersions(std::string Version1, std::string Version2) } +void PageManager::replaceSZ(std::string &str, const bool &remove) +{ + struct { + const std::string search; + const std::string replace; + } specialCharacters[] = { + {"&", "&"}, + {""", "\""}, + {"<", "<"}, + {">", ">"}, + {"'", "'"}, + {"'", "'"}, + {"!", "!"}, + {"#", "#"}, + {"$", "$"}, + {"%", "%"}, + {"*", "*"}, + {"+", "+"}, + {",", ","}, + {".", "."}, + {"/", "/"}, + {":", ":"}, + {";", ";"}, + {"=", "="}, + {"?", "?"}, + {"@", "@"}, + {"[", "["}, + {"\", "\\"}, + {"]", "]"}, + {"^", "^"}, + {"_", "_"}, + {"`", "`"}, + {"{", "{"}, + {"|", "|"}, + {"}", "}"}, + {"˜", "~"}, + {"'", "'"}, + {"
", " "} + }; + + for (const auto& entry : specialCharacters) { + if (str.find(entry.search) != std::string::npos) { + str = replace(str, entry.search, ((remove) ? "" : entry.replace)); + } + if(remove && str.find(entry.replace) != std::string::npos) { + str = replace(str, entry.replace, ""); + } + } +} + int PageManager::writeToFile(std::vector paths, std::string text) { if(paths.size() == 0) @@ -758,6 +830,31 @@ std::string PageManager::getCurlVersion() return data->version; } +std::string PageManager::generateRandomString(int length) { + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + std::string randomString; + for (int i = 0; i < length; ++i) { + randomString.push_back(alphanum[std::rand() % (sizeof(alphanum) - 1)]); + } + + return randomString; +} + +void PageManager::generateNewTorAnmeldeNamen(std::string alterName) { + torAnmeldeNamenMutex.lock(); + + if(torAnmeldeNamen == alterName) { + torAnmeldeNamen = generateRandomString(10); + std::cout << " -> New Proxy Login Name: " << torAnmeldeNamen << std::flush; + usleep(700000); + } + torAnmeldeNamenMutex.unlock(); +} + std::string PageManager::chooseHosterLink(std::string HosterList, std::string Hoster_with_Highst_Priority_at_First, std::string languages_with_highst_priority_at_first, bool withWarnMsg) { diff --git a/src/pageManager.h b/src/pageManager.h index 4308f6e..e4178eb 100644 --- a/src/pageManager.h +++ b/src/pageManager.h @@ -6,17 +6,6 @@ #include "accountManager.h" #include "parameterManager.h" // for isNumber -#ifdef _WIN32 -#include "./../include/curl/curl.h" -#include - -//----------------------????????????????? -#define noSLLCheck - -#else -#include "curl/curl.h" -#endif - #include #include // sleep #include @@ -24,10 +13,6 @@ #include - -#define USER_AGENT "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" - - struct Reply { Reply() {} Reply(std::string value_both) : html(value_both), url(value_both) {} @@ -77,6 +62,8 @@ public: int compareVersions(std::string Version1, std::string Version2); + void replaceSZ(std::string &str, const bool &remove = false); + int writeToFile(std::vector paths, std::string text); static std::string getCurlVersion(); @@ -86,30 +73,9 @@ public: static std::string torAnmeldeNamen; static bool cloudflare_protec; - static std::string generateRandomString(int length) { - static const char alphanum[] = - "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; + static std::string generateRandomString(int length); - std::string randomString; - for (int i = 0; i < length; ++i) { - randomString.push_back(alphanum[std::rand() % (sizeof(alphanum) - 1)]); - } - - return randomString; - } - - static void generateNewTorAnmeldeNamen(std::string alterName) { - torAnmeldeNamenMutex.lock(); - - if(torAnmeldeNamen == alterName) { - torAnmeldeNamen = generateRandomString(10); - std::cout << " -> New Proxy Login Name: " << torAnmeldeNamen << std::flush; - usleep(700000); - } - torAnmeldeNamenMutex.unlock(); - } + static void generateNewTorAnmeldeNamen(std::string alterName); std::string sock5Proxy; private: diff --git a/src/parameterManager.cpp b/src/parameterManager.cpp index 23ff0fd..27f7778 100644 --- a/src/parameterManager.cpp +++ b/src/parameterManager.cpp @@ -1,6 +1,11 @@ #include "parameterManager.h" +#include "logger.h" +//////Wichtig nach MODUS UND PAGE DECLARATION +#include "pageManager.h" + + int setPaths(Settings &settings) { //Path settings diff --git a/src/parameterManager.h b/src/parameterManager.h index 09faf4f..7d0e3c4 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -24,14 +24,12 @@ #define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files=" #define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files=" -#define VERSION "6.2.0" +#define VERSION "6.3.0" #define DEFAULT_FILE_VERSION "2.5" -//default, anime, normal, -//suche: für jede katego. eine -//zu beginn, erst eiunmal serie suchen - +// user agent +#define USER_AGENT "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36" enum Modus { @@ -52,18 +50,10 @@ enum Modus { struct PAGE { PAGE() {} PAGE( std::string protocol, std::string url, std::string nameID, std::string urlAphabetSerienList, std::string urlDir, std::string popularSerien ) - : protocol(protocol), name_id(nameID), url(url), urlAlphabetSerienList(urlAphabetSerienList), UrlDir(urlDir), popularSerien(popularSerien) - { - - } + : protocol(protocol), name_id(nameID), url(url), urlAlphabetSerienList(urlAphabetSerienList), UrlDir(urlDir), popularSerien(popularSerien) { } std::string protocol, name_id, url, urlAlphabetSerienList, UrlDir, popularSerien; }; -#include "logger.h" - -//////Wichtig nach MODUS UND PAGE DECLARATION -#include "pageManager.h" - struct Settings { const std::string programName = "S_New4"; diff --git a/src/programManager.cpp b/src/programManager.cpp index 6612f78..5ae9b44 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -1909,7 +1909,7 @@ int ProgramManager::searchModus_update(Settings *settings) //darf nicht weniger werden!! for ( const auto &page : settings->pagesInUse ) { - std::cout << " -> Updating '" << page.name_id << "'..." << std::endl; + std::cout << " -> Updating '" << page.name_id << " <" << page.url << ">'..." << std::endl; Reply reply = pageManager.getServerRequest( page.protocol, page.url + page.urlAlphabetSerienList); @@ -1962,22 +1962,18 @@ int ProgramManager::searchModus_update(Settings *settings) line = replace(line, "", ""); //...\n|/serie/ stream/2012-das-jahr-null"_weg_>2012 - Das Jahr Null|\n... + + ///Nadia The Secret, Fushigi no Nadia|/nadia-zauberstein|Nadia und Zauberstein|seriento serienListe += line + "|" + page.url + "\n"; } if(serienListe.length() > 0) serienListe.pop_back(); - //Entferne Html Sonderzeichen - serienListe = replace(serienListe, "&quot;", "\""); // + //ersetze html sonderzeichen... + pageManager.replaceSZ(serienListe); + serienListe = replace(serienListe, "--", "-"); - serienListe = replace(serienListe, "&", "&"); // - serienListe = replace(serienListe, "<", "<"); // - serienListe = replace(serienListe, ">", ">"); // - - serienListe = replace(serienListe, "
", " "); // - serienListe = replace(serienListe, """, "\""); // - serienListe = replace(serienListe, "'", "'"); // list += serienListe; diff --git a/src/programManager.h b/src/programManager.h index 773ba89..b488508 100644 --- a/src/programManager.h +++ b/src/programManager.h @@ -2,9 +2,9 @@ #define MANAGEPROGRAM_H -//#include "pageManager.h" #include "parameterManager.h" -//#include "accountManager.h" +#include "accountManager.h" +#include "pageManager.h" #include #include