mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
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:
parent
03898a2123
commit
400d263e40
|
@ -40,6 +40,7 @@
|
||||||
#include "decompress.hh"
|
#include "decompress.hh"
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
#include "ripemd.hh"
|
#include "ripemd.hh"
|
||||||
|
#include "utils.hh"
|
||||||
|
|
||||||
namespace Mdict
|
namespace Mdict
|
||||||
{
|
{
|
||||||
|
@ -183,8 +184,6 @@ QString MdictParser::toUtf16( const char * fromCode, const char * from, size_t f
|
||||||
if ( !fromCode || !from )
|
if ( !fromCode || !from )
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QTextCodec *codec =QTextCodec::codecForName(fromCode);
|
QTextCodec *codec =QTextCodec::codecForName(fromCode);
|
||||||
return codec->toUnicode(from,fromSize);
|
return codec->toUnicode(from,fromSize);
|
||||||
}
|
}
|
||||||
|
@ -647,7 +646,7 @@ QString & MdictParser::substituteStylesheet( QString & article, MdictParser::Sty
|
||||||
}
|
}
|
||||||
if( pos )
|
if( pos )
|
||||||
{
|
{
|
||||||
articleNewText += article.mid( pos );
|
articleNewText += Utils::rstripnull( article.mid( pos ));
|
||||||
article = articleNewText;
|
article = articleNewText;
|
||||||
articleNewText.clear();
|
articleNewText.clear();
|
||||||
}
|
}
|
||||||
|
|
16
utils.hh
16
utils.hh
|
@ -26,6 +26,22 @@ inline QString rstrip(const QString &str) {
|
||||||
return "";
|
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) {
|
inline bool isExternalLink(QUrl const &url) {
|
||||||
return url.scheme() == "http" || url.scheme() == "https" ||
|
return url.scheme() == "http" || url.scheme() == "https" ||
|
||||||
url.scheme() == "ftp" || url.scheme() == "mailto" ||
|
url.scheme() == "ftp" || url.scheme() == "mailto" ||
|
||||||
|
|
Loading…
Reference in a new issue