From 22fcc8fe4d2d9f8260ffb8ef40ceb03cd9e104fb Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Thu, 11 Aug 2016 12:29:16 +0200 Subject: [PATCH] - movieinfo: more cleanup; use htmlEntityDecode from helpers.cpp --- src/gui/moviebrowser.cpp | 2 +- src/gui/movieinfo.cpp | 31 +++---------------------------- src/system/helpers.cpp | 2 ++ 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index f3be417db..711be53dc 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1871,7 +1871,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) std::string extension; extension = fname.substr(ext_pos + 1, fname.length() - ext_pos); extension = "." + extension; - strReplace(fname, extension.c_str(), ".jpg"); + str_replace(extension, ".jpg", fname); printf("TMDB: %s : %s\n",m_movieSelectionHandler->file.Name.c_str(),fname.c_str()); cTmdb* tmdb = new cTmdb(m_movieSelectionHandler->epgTitle); if ((tmdb->getResults() > 0) && (tmdb->hasCover())) { diff --git a/src/gui/movieinfo.cpp b/src/gui/movieinfo.cpp index 608a4789b..b29fb74cb 100644 --- a/src/gui/movieinfo.cpp +++ b/src/gui/movieinfo.cpp @@ -252,7 +252,7 @@ static int find_next_char(char to_find, const char *text, int start_pos, int end while(_pos_ < bytes && _text_[_pos_] != '<' ) _pos_++;\ _dest_ = "";\ _dest_.append(&_text_[pos_prev],_pos_ - pos_prev );\ - _dest_ = decodeXmlSpecialChars(_dest_);\ + _dest_ = htmlEntityDecode(_dest_);\ _pos_ += sizeof(_tag_);\ continue;\ } @@ -276,31 +276,6 @@ static int find_next_char(char to_find, const char *text, int start_pos, int end continue;\ } -void strReplace(std::string &orig, const char *fstr, const std::string &rstr) -{ - // replace all occurrence of fstr with rstr and returns a reference to itself - size_t index = 0; - size_t fstrlen = strlen(fstr); - size_t rstrlen = rstr.size(); - - while ((index = orig.find(fstr, index)) != std::string::npos) { - orig.replace(index, fstrlen, rstr); - index += rstrlen; - } -} - -std::string decodeXmlSpecialChars(std::string s) -{ - strReplace(s,"<","<"); - strReplace(s,">",">"); - strReplace(s,"&","&"); - strReplace(s,""","\""); - strReplace(s,"'","\'"); - strReplace(s," ","\n"); - strReplace(s," ","\n"); - return s; -} - bool CMovieInfo::parseXmlTree(std::string &_text, MI_MOVIE_INFO *movie_info) { int bookmark_nr = 0; @@ -408,7 +383,7 @@ bool CMovieInfo::parseXmlTree(std::string &_text, MI_MOVIE_INFO *movie_info) if (text[pos + pos3] == '\"') { audio_pids.epgAudioPidName.append(&text[pos + pos2 + 1], pos3 - pos2 - 1); - audio_pids.epgAudioPidName = decodeXmlSpecialChars(audio_pids.epgAudioPidName); + audio_pids.epgAudioPidName = htmlEntityDecode(audio_pids.epgAudioPidName); } } } @@ -456,7 +431,7 @@ bool CMovieInfo::parseXmlTree(std::string &_text, MI_MOVIE_INFO *movie_info) if (text[pos + pos3] == '\"') { movie_info->bookmarks.user[bookmark_nr].name.append(&text[pos + pos2 + 1], pos3 - pos2 - 1); - movie_info->bookmarks.user[bookmark_nr].name = decodeXmlSpecialChars(movie_info->bookmarks.user[bookmark_nr].name); + movie_info->bookmarks.user[bookmark_nr].name = htmlEntityDecode(movie_info->bookmarks.user[bookmark_nr].name); } } } diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 70dd11838..d77efa230 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -487,6 +487,8 @@ std::string& htmlEntityDecode(std::string& text) }; decode_table dt[] = { + {"\n", " "}, + {"\n", " "}, {" ", " "}, {"&", "&"}, {"<", "<"},