From 03d3e0e179d9cc659e1c501c65c8dc799165b65c Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 9 May 2018 06:36:48 +0200 Subject: [PATCH] replaced own unescape_html() with the one from mastodon-cpp --- CMakeLists.txt | 2 +- README.md | 2 +- src/parse.cpp | 42 +----------------------------------------- 3 files changed, 3 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcb5321..d8c4999 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastorss - VERSION 0.5.15 + VERSION 0.5.16 LANGUAGES CXX ) diff --git a/README.md b/README.md index 0ac85ef..038203a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The documentation is far from complete, sorry. * [cmake](https://cmake.org/) (tested: 3.9.6) * [boost](http://www.boost.org/) (tested: 1.63.0) * [curlpp](http://www.curlpp.org/) (tested: 0.8.1) - * [mastodon-cpp](https://github.com/tastytea/mastodon-cpp) (at least: 0.8.6) + * [mastodon-cpp](https://github.com/tastytea/mastodon-cpp) (at least: 0.12.0) * [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (tested: 1.8.4) ## Get sourcecode diff --git a/src/parse.cpp b/src/parse.cpp index 7385b68..38c58b1 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -33,46 +33,6 @@ using std::cerr; using std::string; namespace pt = boost::property_tree; -// Translate { to chars, translate some named entities to chars -void unescape_html(string &str) -{ - string html = str; - str = ""; - // Used to convert int to utf-8 char - std::wstring_convert, char32_t> u8c; - std::regex re_entity("&#(x)?(\\d{1,8});"); - std::smatch match; - - while (std::regex_search(html, match, re_entity)) - { - char32_t codepoint = 0; - // 'x' in front of the number means it's hexadecimal, else decimal. - if (match[1].length() == 1) - { - codepoint = std::stoi(match[2].str(), nullptr, 16); - } - else - { - codepoint = std::stoi(match[2].str(), nullptr, 10); - } - str += match.prefix().str() + u8c.to_bytes(codepoint); - html = match.suffix().str(); - } - str += html; - - std::regex relt("<"); - std::regex regt(">"); - std::regex reamp("&"); - std::regex requot("""); - std::regex reapos("'"); - - str = std::regex_replace(str, relt, "<"); - str = std::regex_replace(str, regt, ">"); - str = std::regex_replace(str, reamp, "&"); - str = std::regex_replace(str, requot, "\""); - str = std::regex_replace(str, reapos, "\'"); -} - std::vector parse_website(const string &xml) { Json::Value list; @@ -157,7 +117,7 @@ std::vector parse_website(const string &xml) continue; } - unescape_html(str); + Mastodon::API::unescape_html(str); // Try to turn the HTML into human-readable text std::regex reparagraph("

");