diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-18 18:27:11 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-18 18:27:11 +0200 |
commit | 4fe0a037c82332e84b16a6f0e2847a2f9a0bd5d7 (patch) | |
tree | 1789706873ccc7095414f44b1a85fe64b6e62345 /src/plugins | |
parent | f5dc7e2c85436877606af46a011c2fba112185a9 (diff) |
Matrix: add a proper URI parser instead of regex for opening links. Show related body item image when pressing enter (for showing replied to media)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Fourchan.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Mangadex.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Manganelo.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Mangatown.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 1 | ||||
-rw-r--r-- | src/plugins/NyaaSi.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Plugin.cpp | 61 | ||||
-rw-r--r-- | src/plugins/Pornhub.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Youtube.cpp | 1 |
9 files changed, 8 insertions, 61 deletions
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 1d3681a..2938319 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -2,6 +2,7 @@ #include "../../include/DataView.hpp" #include "../../include/Storage.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <json/reader.h> #include <string.h> #include <tidy.h> diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp index f0e163e..0ccecdd 100644 --- a/src/plugins/Mangadex.cpp +++ b/src/plugins/Mangadex.cpp @@ -2,6 +2,7 @@ #include "../../include/Storage.hpp" #include "../../include/Notification.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <rapidjson/document.h> #include <rapidjson/reader.h> #include <quickmedia/HtmlSearch.h> diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index e96bc65..b260dea 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -1,6 +1,7 @@ #include "../../plugins/Manganelo.hpp" #include "../../include/Notification.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <quickmedia/HtmlSearch.h> namespace QuickMedia { diff --git a/src/plugins/Mangatown.cpp b/src/plugins/Mangatown.cpp index 5d6f97f..992e0cc 100644 --- a/src/plugins/Mangatown.cpp +++ b/src/plugins/Mangatown.cpp @@ -1,6 +1,7 @@ #include "../../plugins/Mangatown.hpp" #include "../../include/Notification.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <quickmedia/HtmlSearch.h> static const std::string mangatown_url = "https://www.mangatown.com"; diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 5cf4611..d81c53c 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1,6 +1,7 @@ #include "../../plugins/Matrix.hpp" #include "../../include/Storage.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <rapidjson/document.h> #include <rapidjson/writer.h> #include <rapidjson/stringbuffer.h> diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index dc6e19f..860eb71 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -3,6 +3,7 @@ #include "../../include/Storage.hpp" #include "../../include/Notification.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <quickmedia/HtmlSearch.h> namespace QuickMedia { diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp index 3f76b4c..0b554ae 100644 --- a/src/plugins/Plugin.cpp +++ b/src/plugins/Plugin.cpp @@ -1,67 +1,6 @@ #include "../../plugins/Plugin.hpp" -#include "../../include/StringUtils.hpp" -#include <sstream> -#include <iomanip> -#include <array> namespace QuickMedia { - struct HtmlEscapeSequence { - char unescape_char; - std::string escape_sequence; - }; - - void html_escape_sequences(std::string &str) { - const std::array<HtmlEscapeSequence, 6> escape_sequences = { - HtmlEscapeSequence { '&', "&" }, // This should be first, to not accidentally replace a new sequence caused by replacing this - HtmlEscapeSequence { '"', """ }, - HtmlEscapeSequence { '\'', "'" }, - HtmlEscapeSequence { '<', "<" }, - HtmlEscapeSequence { '>', ">" }, - HtmlEscapeSequence { '\n', "<br>" } - }; - - for(const HtmlEscapeSequence &escape_sequence : escape_sequences) { - string_replace_all(str, escape_sequence.unescape_char, escape_sequence.escape_sequence); - } - } - - struct HtmlUnescapeSequence { - std::string escape_sequence; - std::string unescaped_str; - }; - - void html_unescape_sequences(std::string &str) { - const std::array<HtmlUnescapeSequence, 6> unescape_sequences = { - HtmlUnescapeSequence { """, "\"" }, - HtmlUnescapeSequence { "'", "'" }, - HtmlUnescapeSequence { "'", "'" }, - HtmlUnescapeSequence { "<", "<" }, - HtmlUnescapeSequence { ">", ">" }, - HtmlUnescapeSequence { "&", "&" } // This should be last, to not accidentally replace a new sequence caused by replacing this - }; - - for(const HtmlUnescapeSequence &unescape_sequence : unescape_sequences) { - string_replace_all(str, unescape_sequence.escape_sequence, unescape_sequence.unescaped_str); - } - } - - std::string url_param_encode(const std::string ¶m) { - std::ostringstream result; - result.fill('0'); - result << std::hex; - - for(char c : param) { - if(isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { - result << c; - } else { - result << std::uppercase; - result << "%" << std::setw(2) << (int)(unsigned char)(c); - } - } - - return result.str(); - } - SuggestionResult download_result_to_suggestion_result(DownloadResult download_result) { return (SuggestionResult)download_result; } PluginResult download_result_to_plugin_result(DownloadResult download_result) { return (PluginResult)download_result; } SearchResult download_result_to_search_result(DownloadResult download_result) { return (SearchResult)download_result; } diff --git a/src/plugins/Pornhub.cpp b/src/plugins/Pornhub.cpp index afdd8fc..e8df9d7 100644 --- a/src/plugins/Pornhub.cpp +++ b/src/plugins/Pornhub.cpp @@ -1,5 +1,6 @@ #include "../../plugins/Pornhub.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/NetUtils.hpp" #include <quickmedia/HtmlSearch.h> #include <string.h> diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 1711e41..424a8d2 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -1,5 +1,6 @@ #include "../../plugins/Youtube.hpp" #include "../../include/Storage.hpp" +#include "../../include/NetUtils.hpp" #include <string.h> #include <unordered_set> |