fix:mdx compact html ,the end close tag error

some mdx entry item has such item
`1`abc.jpg\r\n\u0000
when replaced with predefined tags. will result in
<a href="abc.jpg\r\n\u0000">****
This commit is contained in:
xiaoyifang 2022-04-16 15:14:26 +08:00
parent 03898a2123
commit 400d263e40
2 changed files with 18 additions and 3 deletions

View file

@ -40,6 +40,7 @@
#include "decompress.hh"
#include "gddebug.hh"
#include "ripemd.hh"
#include "utils.hh"
namespace Mdict
{
@ -183,8 +184,6 @@ QString MdictParser::toUtf16( const char * fromCode, const char * from, size_t f
if ( !fromCode || !from )
return QString();
QTextCodec *codec =QTextCodec::codecForName(fromCode);
return codec->toUnicode(from,fromSize);
}
@ -647,7 +646,7 @@ QString & MdictParser::substituteStylesheet( QString & article, MdictParser::Sty
}
if( pos )
{
articleNewText += article.mid( pos );
articleNewText += Utils::rstripnull( article.mid( pos ));
article = articleNewText;
articleNewText.clear();
}

View file

@ -26,6 +26,22 @@ inline QString rstrip(const QString &str) {
return "";
}
/**
* str="abc\r\n\u0000" should be returned as "abc"
* @brief rstripnull
* @param str
* @return
*/
inline QString rstripnull(const QString &str) {
int n = str.size() - 1;
for (; n >= 0; --n) {
if (!str.at(n).isSpace()&&!str.at(n).isNull()) {
return str.left(n + 1);
}
}
return "";
}
inline bool isExternalLink(QUrl const &url) {
return url.scheme() == "http" || url.scheme() == "https" ||
url.scheme() == "ftp" || url.scheme() == "mailto" ||