diff --git a/aard.cc b/aard.cc index a0072932..cc2c3563 100644 --- a/aard.cc +++ b/aard.cc @@ -392,16 +392,16 @@ string AardDictionary::convert( const string & in ) QString text = QString::fromUtf8( inConverted.c_str() ); - text.replace( QRegularExpression( "<\\s*a\\s+href\\s*=\\s*\\\"(w:|s:){0,1}([^#](?!ttp://)[^\\\"]*)(.)", + text.replace( QRegularExpression( R"(<\s*a\s+href\s*=\s*\"(w:|s:){0,1}([^#](?!ttp://)[^\"]*)(.))", QRegularExpression::DotMatchesEverythingOption ), - "]*)/>", QRegularExpression::CaseInsensitiveOption ); //
diff --git a/article_maker.cc b/article_maker.cc index 3c91215f..b26607ab 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -59,15 +59,15 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, result += ""; //custom javascript - result += ""; + result += R"()"; //iframe resizer javascript - result += ""; + result += R"()"; } // add qwebchannel { - result += ""; + result += R"()"; } // document ready ,init webchannel @@ -84,14 +84,14 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, // Add a css stylesheet { - result += ""; + result += R"()"; if ( displayStyle.size() ) { // Load an additional stylesheet QString displayStyleCssFile = QString("qrc:///article-style-st-%1.css").arg(displayStyle); result += ""; + R"(" media="all" rel="stylesheet" type="text/css">)"; } result += readCssFile(Config::getUserCssFileName() ,"all"); @@ -117,7 +117,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, // Add print-only css { - result += ""; + result += R"()"; result += readCssFile(Config::getUserCssPrintFileName() ,"print"); @@ -134,20 +134,20 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, // This doesn't seem to be much of influence right now, but we'll keep // it anyway. if ( icon.size() ) - result += "\n"; + result += R"(\n"; result += ""; - result+= ""; + result+= R"()"; #ifdef Q_OS_WIN32 if( GlobalBroadcaster::instance()->getPreference()->darkMode ) @@ -175,7 +175,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, QByteArray css = addonCss.readAll(); if (!css.isEmpty()) { result += "\n"; - result += "\n"; } @@ -585,7 +585,7 @@ void ArticleRequest::bodyFinished() if ( closePrevSpan ) { - head += "
"; + head += R"(
)"; } bool collapse = false; @@ -637,15 +637,15 @@ void ArticleRequest::bodyFinished() closePrevSpan = true; - head += string( "
" + + + R"(>)" + Html::escape( tr( "From " ).toUtf8().data() ) + "" + Html::escape( activeDict->getName().c_str() ) + "" - + "]*>", QRegularExpression::CaseInsensitiveOption ) ) - .remove( QRegularExpression( "[\\s\\S]*?<\\/script>", QRegularExpression::CaseInsensitiveOption|QRegularExpression::MultilineOption ) ); + .remove( QRegularExpression( R"([\s\S]*?<\/script>)", QRegularExpression::CaseInsensitiveOption|QRegularExpression::MultilineOption ) ); int size = QTextDocumentFragment::fromHtml( stripStyleSheet ).toPlainText().length(); return size; @@ -800,7 +800,7 @@ void ArticleRequest::stemmedSearchFinished() if ( sr.size() ) { - footer += "
" + + footer += R"(
)" + Html::escape( tr( "Close words: " ).toUtf8().data() ) + ""; @@ -871,7 +871,7 @@ void ArticleRequest::compoundSearchNextStep( bool lastSearchSucceeded ) if ( !firstCompoundWasFound ) { // Append the beginning - footer += "
" + + footer += R"(
)" + Html::escape( tr( "Compound expressions: " ).toUtf8().data() ) + ""; @@ -899,7 +899,7 @@ void ArticleRequest::compoundSearchNextStep( bool lastSearchSucceeded ) // Now add links to all the individual words. They conclude the result. - footer += "
" + + footer += R"(
)" + Html::escape( tr( "Individual words: " ).toUtf8().data() ) + "]+|\\s*)>)", +QRegularExpression Mdx::allLinksRe( R"((?:<\s*(a(?:rea)?|img|link|script|source)(?:\s+[^>]+|\s*)>))", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::wordCrossLink( "([\\s\"']href\\s*=)\\s*([\"'])entry://([^>#]*?)((?:#[^>]*?)?)\\2", +QRegularExpression Mdx::wordCrossLink( R"(([\s"']href\s*=)\s*(["'])entry://([^>#]*?)((?:#[^>]*?)?)\2)", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::anchorIdRe( "([\\s\"'](?:name|id)\\s*=)\\s*([\"'])\\s*(?=\\S)", +QRegularExpression Mdx::anchorIdRe( R"(([\s"'](?:name|id)\s*=)\s*(["'])\s*(?=\S))", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::anchorIdReWord( "([\\s\"'](?:name|id)\\s*=)\\s*([\"'])\\s*(?=\\S)([^\"]*)", +QRegularExpression Mdx::anchorIdReWord( R"(([\s"'](?:name|id)\s*=)\s*(["'])\s*(?=\S)([^"]*))", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::anchorIdRe2( "([\\s\"'](?:name|id)\\s*=)\\s*(?=[^\"'])([^\\s\">]+)", +QRegularExpression Mdx::anchorIdRe2( R"(([\s"'](?:name|id)\s*=)\s*(?=[^"'])([^\s">]+))", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::anchorLinkRe( "([\\s\"']href\\s*=\\s*[\"'])entry://#", +QRegularExpression Mdx::anchorLinkRe( R"(([\s"']href\s*=\s*["'])entry://#)", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::audioRe( "([\\s\"']href\\s*=)\\s*([\"'])sound://([^\">]+)\\2", +QRegularExpression Mdx::audioRe( R"(([\s"']href\s*=)\s*(["'])sound://([^">]+)\2)", QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ); QRegularExpression Mdx::stylesRe( "([\\s\"']href\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://" @@ -45,7 +45,7 @@ QRegularExpression Mdx::stylesRe( "([\\s\"']href\\s*=)\\s*([\"'])(?!\\s*\\b(?:(? QRegularExpression Mdx::stylesRe2( "([\\s\"']href\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://" "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::inlineScriptRe( "<\\s*script(?:(?=\\s)(?:(?![\\s\"']src\\s*=)[^>])+|\\s*)>", +QRegularExpression Mdx::inlineScriptRe( R"(<\s*script(?:(?=\s)(?:(?![\s"']src\s*=)[^>])+|\s*)>)", QRegularExpression::CaseInsensitiveOption ); QRegularExpression Mdx::closeScriptTagRe( "<\\s*/script\\s*>", QRegularExpression::CaseInsensitiveOption ); QRegularExpression Mdx::srcRe( "([\\s\"'](?:src|srcset)\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://" @@ -55,13 +55,13 @@ QRegularExpression Mdx::srcRe2( "([\\s\"'](?:src|srcset)\\s*=)\\s*(?![\\s\"']|\\ "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::links( "url\\(\\s*(['\"]?)([^'\"]*)(['\"]?)\\s*\\)", +QRegularExpression Mdx::links( R"(url\(\s*(['"]?)([^'"]*)(['"]?)\s*\))", QRegularExpression::CaseInsensitiveOption ); -QRegularExpression Mdx::fontFace( "(?:url\\s*\\(\\s*\\\"(.*?)\\\"\\s*)\\)", +QRegularExpression Mdx::fontFace( R"((?:url\s*\(\s*\"(.*?)\"\s*)\))", QRegularExpression::CaseInsensitiveOption|QRegularExpression::DotMatchesEverythingOption ); -QRegularExpression Mdx::styleElment( "(]*>)([\\w\\W]*?)(<\\/style>)", +QRegularExpression Mdx::styleElment( R"((]*>)([\w\W]*?)(<\/style>))", QRegularExpression::CaseInsensitiveOption); diff --git a/bgl.cc b/bgl.cc index be2bdf4a..aba2ae30 100644 --- a/bgl.cc +++ b/bgl.cc @@ -890,20 +890,20 @@ void BglArticleRequest::run() result = QString::fromUtf8( result.c_str() ) // onclick location to link - .replace( QRegularExpression( "<([a-z0-9]+)\\s+[^>]*onclick=\"[a-z.]*location(?:\\.href)\\s*=\\s*'([^']+)[^>]*>([^<]+)", + .replace( QRegularExpression( R"(<([a-z0-9]+)\s+[^>]*onclick="[a-z.]*location(?:\.href)\s*=\s*'([^']+)[^>]*>([^<]+))", QRegularExpression::CaseInsensitiveOption ), - "\\3") - .replace( QRegularExpression( "(<\\s*a\\s+[^>]*href\\s*=\\s*[\"']\\s*)bword://", + R"(\3)") + .replace( QRegularExpression( R"((<\s*a\s+[^>]*href\s*=\s*["']\s*)bword://)", QRegularExpression::CaseInsensitiveOption ), "\\1bword:" ) //remove invalid width, height attrs - .replace( QRegularExpression( "(width|height)\\s*=\\s*[\"']\\d{7,}[\"'']" ), + .replace( QRegularExpression( R"((width|height)\s*=\s*["']\d{7,}["''])" ), "" ) //remove invalid
tag - .replace( QRegularExpression( "
(|||||function addScript|var scNode|scNode|var atag|while\\(atag|atag=atag|document\\.getElementsByTagName|addScript|src=\"bres|(|||||function addScript|var scNode|scNode|var atag|while\(atag|atag=atag|document\.getElementsByTagName|addScript|src="bres||addScript\\('JS_FILE_PHONG_VT_45634'\\);|appendChild\\(scNode\\);|atag\\.firstChild;)
", + .replace( QRegularExpression( R"((AUTOSTATUS, WRAP\);" |
|addScript\('JS_FILE_PHONG_VT_45634'\);|appendChild\(scNode\);|atag\.firstChild;)
)", QRegularExpression::CaseInsensitiveOption ), " \\1 " ) .toUtf8().data(); @@ -1079,7 +1079,7 @@ sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name { QString str = QString::fromUtf8( text.c_str() ); - QRegularExpression charsetExp( "<\\s*charset\\s+c\\s*=\\s*[\"']?t[\"']?\\s*>((?:\\s*[0-9a-fA-F]+\\s*;\\s*)*)<\\s*/\\s*charset\\s*>", + QRegularExpression charsetExp( R"(<\s*charset\s+c\s*=\s*["']?t["']?\s*>((?:\s*[0-9a-fA-F]+\s*;\s*)*)<\s*/\s*charset\s*>)", QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ); diff --git a/dictdfiles.cc b/dictdfiles.cc index 00d94962..4de4d047 100644 --- a/dictdfiles.cc +++ b/dictdfiles.cc @@ -341,9 +341,9 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor } else { - static QRegularExpression phonetic( "\\\\([^\\\\]+)\\\\", + static QRegularExpression phonetic( R"(\\([^\\]+)\\)", QRegularExpression::CaseInsensitiveOption ); // phonetics: \stuff\ ... - static QRegularExpression refs( "\\{([^\\{\\}]+)\\}", + static QRegularExpression refs( R"(\{([^\{\}]+)\})", QRegularExpression::CaseInsensitiveOption ); // links: {stuff} static QRegularExpression links( "
", QRegularExpression::CaseInsensitiveOption ); @@ -360,8 +360,8 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor free( articleBody ); QString articleString = QString::fromUtf8( convertedText.c_str() ) - .replace(phonetic, "\\1") - .replace(refs, "\\1"); + .replace(phonetic, R"(\1)") + .replace(refs, R"(\1)"); convertedText.erase(); int pos = 0; @@ -546,17 +546,17 @@ void DictdDictionary::getArticleText( uint32_t articleAddress, QString & headwor } else { - static QRegularExpression phonetic( "\\\\([^\\\\]+)\\\\", + static QRegularExpression phonetic( R"(\\([^\\]+)\\)", QRegularExpression::CaseInsensitiveOption ); // phonetics: \stuff\ ... - static QRegularExpression refs( "\\{([^\\{\\}]+)\\}", + static QRegularExpression refs( R"(\{([^\{\}]+)\})", QRegularExpression::CaseInsensitiveOption ); // links: {stuff} string convertedText = Html::preformat( articleBody, isToLanguageRTL() ); free( articleBody ); text = QString::fromUtf8( convertedText.data(), convertedText.size() ) - .replace(phonetic, "\\1") - .replace(refs, "\\1"); + .replace(phonetic, R"(\1)") + .replace(refs, R"(\1)"); text = Html::unescape( text ); } diff --git a/dictionary.cc b/dictionary.cc index 9ef7d6e9..ccee65e4 100644 --- a/dictionary.cc +++ b/dictionary.cc @@ -345,9 +345,9 @@ void Class::isolateCSS( QString & css, QString const & wrapperSelector ) if( css.isEmpty() ) return; - QRegularExpression reg1( "\\/\\*(?:.(?!\\*\\/))*.?\\*\\/", + QRegularExpression reg1( R"(\/\*(?:.(?!\*\/))*.?\*\/)", QRegularExpression::DotMatchesEverythingOption ); - QRegularExpression reg2( "[ \\*\\>\\+,;:\\[\\{\\]]" ); + QRegularExpression reg2( R"([ \*\>\+,;:\[\{\]])" ); QRegularExpression reg3( "[,;\\{]" ); diff --git a/dictserver.cc b/dictserver.cc index ab49615f..4845cc75 100644 --- a/dictserver.cc +++ b/dictserver.cc @@ -799,11 +799,11 @@ void DictServerArticleRequest::run() if( Utils::AtomicInt::loadAcquire( isCancelled ) || !errorString.isEmpty() ) break; - static QRegularExpression phonetic( "\\\\([^\\\\]+)\\\\", + static QRegularExpression phonetic( R"(\\([^\\]+)\\)", QRegularExpression::CaseInsensitiveOption ); // phonetics: \stuff\ ... static QRegularExpression divs_inside_phonetic( "]*)>]*)>", QRegularExpression::CaseInsensitiveOption ); - static QRegularExpression refs( "\\{([^\\{\\}]+)\\}", + static QRegularExpression refs( R"(\{([^\{\}]+)\})", QRegularExpression::CaseInsensitiveOption ); // links: {stuff} static QRegularExpression links( "", QRegularExpression::CaseInsensitiveOption ); @@ -819,7 +819,7 @@ void DictServerArticleRequest::run() articleText = QString::fromUtf8( articleStr.c_str(), articleStr.size() ); if( !contentInHtml ) { - articleText = articleText.replace(refs, "\\1" ); + articleText = articleText.replace(refs, R"(\1)" ); pos = 0; QString articleNewText; @@ -834,7 +834,7 @@ void DictServerArticleRequest::run() pos = match.capturedEnd(); QString phonetic_text = match.captured( 1 ); - phonetic_text.replace( divs_inside_phonetic, "" ); + phonetic_text.replace( divs_inside_phonetic, R"()" ); articleNewText += "" + phonetic_text + ""; } diff --git a/dsl.cc b/dsl.cc index 32eab1f9..d6354966 100644 --- a/dsl.cc +++ b/dsl.cc @@ -826,7 +826,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) string id = "O" + getId().substr( 0, 7 ) + "_" + QString::number( articleNom ).toStdString() + "_opt_" + QString::number( optionalPartNom++ ).toStdString(); - result += "" + processNodeChildren( node ) + ""; + result += R"(" + processNodeChildren( node ) + ""; } else if( node.tagName == U"m" ) result += "
" + processNodeChildren( node ) + "
"; @@ -869,7 +869,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; } else if ( Filetype::isNameOfPicture( filename ) ) @@ -968,7 +968,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) url.setHost( QString::fromUtf8( getId().c_str() ) ); url.setPath( Utils::Url::ensureLeadingSlash( QString::fromUtf8( filename.c_str() ) ) ); - result += string( "" + result += string( R"(" + "" + "" + processNodeChildren( node ) + "" + ""; } @@ -981,7 +981,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) url.setHost( QString::fromUtf8( getId().c_str() ) ); url.setPath( Utils::Url::ensureLeadingSlash( QString::fromUtf8( filename.c_str() ) ) ); - result += string( "" + processNodeChildren( node ) + ""; } } @@ -1006,7 +1006,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) } } - result += "" + processNodeChildren( node ) + ""; + result += R"(" + processNodeChildren( node ) + ""; } else if( node.tagName == U"!trs" ) { @@ -1065,7 +1065,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) // We generate two spans, one with accented data and another one without it, so the // user could pick up the best suitable option. string data = processNodeChildren( node ); - result += "" + data + "" + result += R"()" + data + "" + "" + data + Utf8::encode( wstring( 1, 0x301 ) ) + ""; } @@ -1123,7 +1123,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) } } - result += string( "" + result += string( R"(" + processNodeChildren( node ) + ""; } else if( node.tagName == U"@" ) @@ -1138,7 +1138,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) normalizeHeadword( nodeStr ); url.setPath( Utils::Url::ensureLeadingSlash( gd::toQString( nodeStr ) ) ); - result += string( "" + result += string( R"(" + processNodeChildren( node ) + ""; } else if( node.tagName == U"sub" ) @@ -1159,7 +1159,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) } else { - gdWarning( "DSL: Unknown tag \"%s\" with attributes \"%s\" found in \"%s\", article \"%s\".", + gdWarning( R"(DSL: Unknown tag "%s" with attributes "%s" found in "%s", article "%s".)", gd::toQString( node.tagName ).toUtf8().data(), gd::toQString( node.tagAttrs ).toUtf8().data(), getName().c_str(), gd::toQString( currentHeadword ).toUtf8().data() ); @@ -1513,9 +1513,9 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword, // Strip tags - text.replace( QRegularExpression( "\\[(|/)(p|trn|ex|com|\\*|t|br|m[0-9]?)\\]" ), " " ); - text.replace( QRegularExpression( "\\[(|/)lang(\\s[^\\]]*)?\\]" ), " " ); - text.remove( QRegularExpression( "\\[[^\\\\\\[\\]]+\\]" ) ); + text.replace( QRegularExpression( R"(\[(|/)(p|trn|ex|com|\*|t|br|m[0-9]?)\])" ), " " ); + text.replace( QRegularExpression( R"(\[(|/)lang(\s[^\]]*)?\])" ), " " ); + text.remove( QRegularExpression( R"(\[[^\\\[\]]+\])" ) ); text.remove( QString::fromLatin1( "<<" ) ); text.remove( QString::fromLatin1( ">>" ) ); @@ -1698,7 +1698,7 @@ void DslArticleRequest::run() string prefix = "O" + dict.getId().substr( 0, 7 ) + "_" + QString::number( dict.articleNom ).toStdString(); string id1 = prefix + "_expand"; string id2 = prefix + "_opt_"; - string button = " \"[+]\"/"; if( articleText.compare( articleText.size() - 4, 4, "

" ) == 0 ) articleText.insert( articleText.size() - 4, " " + button ); diff --git a/dsl_details.cc b/dsl_details.cc index 569a2d55..fab35bd9 100644 --- a/dsl_details.cc +++ b/dsl_details.cc @@ -145,7 +145,7 @@ string findCodeForDslId( int id ) bool isAtSignFirst( wstring const & str ) { // Test if '@' is first in string except spaces and dsl tags - QRegularExpression reg( "[ \\t]*(?:\\[[^\\]]+\\][ \\t]*)*@", QRegularExpression::PatternOption::CaseInsensitiveOption); + QRegularExpression reg( R"([ \t]*(?:\[[^\]]+\][ \t]*)*@)", QRegularExpression::PatternOption::CaseInsensitiveOption); return gd::toQString( str ).indexOf (reg) == 0; } @@ -356,11 +356,11 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, catch( eot ) { if( !dictionaryName.empty() ) - gdWarning( "DSL: Unfinished tag \"%s\" with attributes \"%s\" found in \"%s\", article \"%s\".", + gdWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found in "%s", article "%s".)", gd::toQString( name ).toUtf8().data(), gd::toQString( attrs ).toUtf8().data(), dictionaryName.c_str(), gd::toQString( headword ).toUtf8().data() ); else - gdWarning( "DSL: Unfinished tag \"%s\" with attributes \"%s\" found", + gdWarning( R"(DSL: Unfinished tag "%s" with attributes "%s" found)", gd::toQString( name ).toUtf8().data(), gd::toQString( attrs ).toUtf8().data() ); throw eot(); @@ -814,7 +814,7 @@ void ArticleDom::closeTag( wstring const & name, if ( warn ) { if( !dictionaryName.empty() ) - gdWarning( "No corresponding opening tag for closing tag \"%s\" found in \"%s\", article \"%s\".", + gdWarning( R"(No corresponding opening tag for closing tag "%s" found in "%s", article "%s".)", gd::toQString( name ).toUtf8().data(), dictionaryName.c_str(), gd::toQString( headword ).toUtf8().data() ); else diff --git a/epwing_book.cc b/epwing_book.cc index 5a95a807..9c230950 100644 --- a/epwing_book.cc +++ b/epwing_book.cc @@ -1041,7 +1041,7 @@ void EpwingBook::fixHeadword( QString & headword ) headword.remove( QChar( 0x30FB ) ); // Used in Japan transcription //replace any unicode Number ,Symbol ,Punctuation ,Mark character to whitespace - headword.replace( QRegularExpression( "[\\p{N}\\p{S}\\p{P}\\p{M}]" ), " " ); + headword.replace( QRegularExpression( R"([\p{N}\p{S}\p{P}\p{M}])" ), " " ); //if( isHeadwordCorrect( headword) ) // return; @@ -1320,7 +1320,7 @@ QByteArray EpwingBook::handleColorImage( EB_Hook_Code code, url.setScheme( "bres" ); url.setHost( dictID ); url.setPath( Utils::Url::ensureLeadingSlash( name ) ); - QByteArray urlStr = "

\""

"; if( imageCacheList.contains( name, Qt::CaseSensitive ) ) @@ -1403,7 +1403,7 @@ QByteArray EpwingBook::handleMonoImage( EB_Hook_Code code, url.setScheme( "bres" ); url.setHost( dictID ); url.setPath( Utils::Url::ensureLeadingSlash( name ) ); - QByteArray urlStr = "\"""; if( imageCacheList.contains( name, Qt::CaseSensitive ) ) @@ -1451,7 +1451,7 @@ QByteArray EpwingBook::handleWave( EB_Hook_Code code, const unsigned int * argv { if( code == EB_HOOK_END_WAVE ) - return QByteArray( "\"Play\"/
" ); + return QByteArray( R"(Play
)" ); // Handle EB_HOOK_BEGIN_WAVE @@ -1638,7 +1638,7 @@ QByteArray EpwingBook::handleNarrowFont( const unsigned int * argv, url.setHost( "/"); url.setPath( Utils::Url::ensureLeadingSlash( QDir::fromNativeSeparators( fullName ) ) ); - QByteArray link = ""; + QByteArray link = R"("; if( fontsCacheList.contains( fname, Qt::CaseSensitive ) ) { @@ -1708,7 +1708,7 @@ QByteArray EpwingBook::handleWideFont( const unsigned int * argv, url.setHost( "/"); url.setPath( Utils::Url::ensureLeadingSlash( QDir::fromNativeSeparators( fullName ) ) ); - QByteArray link = ""; + QByteArray link = R"("; if( fontsCacheList.contains( fname, Qt::CaseSensitive ) ) { diff --git a/folding.cc b/folding.cc index 6136b817..abcdbb43 100644 --- a/folding.cc +++ b/folding.cc @@ -667,7 +667,7 @@ void normalizeWhitespace( wstring & str ) QString escapeWildcardSymbols( const QString & str ) { QString escaped( str ); - escaped.replace( QRegularExpression( "([\\[\\]\\?\\*])" ), "\\\\1" ); + escaped.replace( QRegularExpression( R"(([\[\]\?\*]))" ), "\\\\1" ); return escaped; } @@ -675,7 +675,7 @@ QString escapeWildcardSymbols( const QString & str ) QString unescapeWildcardSymbols( const QString & str ) { QString unescaped( str ); - unescaped.replace( QRegularExpression( "\\\\([\\[\\]\\?\\*])" ), "\\1" ); + unescaped.replace( QRegularExpression( R"(\\([\[\]\?\*]))" ), "\\1" ); return unescaped; } diff --git a/forvo.cc b/forvo.cc index 321f0145..f870f9d3 100644 --- a/forvo.cc +++ b/forvo.cc @@ -271,7 +271,7 @@ void ForvoArticleRequest::requestFinished( QNetworkReply * r ) string addTime = tr( "Added %1" ).arg( item.namedItem( "addtime" ).toElement().text() ).toUtf8().data(); - articleBody += "\"Play\"/"; + articleBody += "Play)"; articleBody += string( "" ) + tr( "by" ).toUtf8().data() + " " + Html::escape( user.toUtf8().data() ) diff --git a/gls.cc b/gls.cc index 28030d8b..0a414e9d 100644 --- a/gls.cc +++ b/gls.cc @@ -727,7 +727,7 @@ void GlsDictionary::loadArticle( uint32_t address, } if( isToLanguageRTL() ) - article += "
"; + article += R"(
)"; QString text = QString::fromUtf8( articleBody.c_str(), articleBody.size() ); @@ -743,10 +743,10 @@ void GlsDictionary::loadArticle( uint32_t address, QString & GlsDictionary::filterResource( QString & article ) { - QRegularExpression imgRe( "(<\\s*img\\s+[^>]*src\\s*=\\s*[\"']+)(?!(?:data|https?|ftp|qrcx):)", + QRegularExpression imgRe( R"((<\s*img\s+[^>]*src\s*=\s*["']+)(?!(?:data|https?|ftp|qrcx):))", QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ); - QRegularExpression linkRe( "(<\\s*link\\s+[^>]*href\\s*=\\s*[\"']+)(?!(?:data|https?|ftp):)", + QRegularExpression linkRe( R"((<\s*link\s+[^>]*href\s*=\s*["']+)(?!(?:data|https?|ftp):))", QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ); @@ -755,7 +755,7 @@ QString & GlsDictionary::filterResource( QString & article ) // Handle links to articles - QRegularExpression linksReg( "]*)href\\s*=\\s*['\"](bword://)?([^'\"]+)['\"]", + QRegularExpression linksReg( R"(]*)href\s*=\s*['"](bword://)?([^'"]+)['"])", QRegularExpression::CaseInsensitiveOption ); int pos = 0; @@ -803,7 +803,7 @@ QString & GlsDictionary::filterResource( QString & article ) // Handle "audio" tags - QRegularExpression audioRe( "<\\s*audio\\s+src\\s*=\\s*([\"']+)([^\"']+)([\"'])\\s*>(.*)", + QRegularExpression audioRe( R"(<\s*audio\s+src\s*=\s*(["']+)([^"']+)(["'])\s*>(.*))", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption | QRegularExpression::InvertedGreedinessOption ); @@ -828,7 +828,7 @@ QString & GlsDictionary::filterResource( QString & article ) QString newTag = QString::fromUtf8( ( addAudioLink( href, getId() ) + "" ).c_str() ); newTag += match.captured( 4 ); if( match.captured( 4 ).indexOf( "\"Play\""; + newTag += R"( Play)"; newTag += ""; articleNewText += newTag; @@ -1302,7 +1302,7 @@ void GlsResourceRequest::run() QString id = QString::fromUtf8( dict.getId().c_str() ); int pos = 0; - QRegularExpression links( "url\\(\\s*(['\"]?)([^'\"]*)(['\"]?)\\s*\\)", + QRegularExpression links( R"(url\(\s*(['"]?)([^'"]*)(['"]?)\s*\))", QRegularExpression::CaseInsensitiveOption ); QString newCSS; diff --git a/htmlescape.cc b/htmlescape.cc index 946b1b6c..0dcbdc57 100644 --- a/htmlescape.cc +++ b/htmlescape.cc @@ -159,7 +159,7 @@ QString unescape( QString const & str, bool saveFormat ) QString fromHtmlEscaped( QString const & str){ QString retVal = str; - QRegularExpression regExp("(?\\<\\;)|(?\\>\\;)|(?\\&\\;)|(?\\"\\;)", QRegularExpression::PatternOption::CaseInsensitiveOption); + QRegularExpression regExp(R"((?\<\;)|(?\>\;)|(?\&\;)|(?\"\;))", QRegularExpression::PatternOption::CaseInsensitiveOption); auto match = regExp.match(str, 0); while (match.hasMatch()) diff --git a/hunspell.cc b/hunspell.cc index 58d61bff..cf90325a 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -473,7 +473,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu wstring lowercasedWord = Folding::applySimpleCaseOnly( word ); - static QRegExp cutStem( "^\\s*st:(((\\s+(?!\\w{2}:)(?!-)(?!\\+))|\\S+)+)" ); + static QRegExp cutStem( R"(^\s*st:(((\s+(?!\w{2}:)(?!-)(?!\+))|\S+)+))" ); for( vector< string >::size_type x = 0; x < suggestions.size(); ++x ) { diff --git a/loaddictionaries.cc b/loaddictionaries.cc index 3027f61c..b26ed0f2 100644 --- a/loaddictionaries.cc +++ b/loaddictionaries.cc @@ -396,7 +396,7 @@ void loadDictionaries( QWidget * parent, bool showInitially, ret = ids.insert( dictionaries[ x ]->getId() ); if( !ret.second ) { - gdWarning( "Duplicate dictionary ID found: ID=%s, name=\"%s\", path=\"%s\"", + gdWarning( R"(Duplicate dictionary ID found: ID=%s, name="%s", path="%s")", dictionaries[ x ]->getId().c_str(), dictionaries[ x ]->getName().c_str(), dictionaries[ x ]->getDictionaryFilenames().empty() ? diff --git a/lsa.cc b/lsa.cc index 7695cc5d..70e2b076 100644 --- a/lsa.cc +++ b/lsa.cc @@ -286,7 +286,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getArticle( wstring const & word, result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; result += "" + i->second + ""; result += ""; } @@ -304,7 +304,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getArticle( wstring const & word, result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; result += "" + i->second + ""; result += ""; } diff --git a/mainwindow.cc b/mainwindow.cc index 71410213..c4b91908 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -3149,11 +3149,11 @@ void MainWindow::latestReleaseReplyReady() if ( latestReleaseReply->error() == QNetworkReply::NoError ) { QString latestReleaseInfo = QString::fromUtf8( latestReleaseReply->readAll() ); - QRegularExpression firstReleaseAnchor ("]*?class=\\\"Link--primary\\\"[^>]*?>[^<]*?<\\/a>",QRegularExpression::DotMatchesEverythingOption|QRegularExpression::CaseInsensitiveOption); + QRegularExpression firstReleaseAnchor (R"(]*?class=\"Link--primary\"[^>]*?>[^<]*?<\/a>)",QRegularExpression::DotMatchesEverythingOption|QRegularExpression::CaseInsensitiveOption); auto match = firstReleaseAnchor.match(latestReleaseInfo); if(match.hasMatch()){ auto releaseAnchor = match.captured(); - QRegularExpression extractReleaseRx ("(.*?)<\\/a>",QRegularExpression::DotMatchesEverythingOption|QRegularExpression::CaseInsensitiveOption); + QRegularExpression extractReleaseRx (R"((.*?)<\/a>)",QRegularExpression::DotMatchesEverythingOption|QRegularExpression::CaseInsensitiveOption); auto matchParts = extractReleaseRx.match(releaseAnchor); if(matchParts.hasMatch()){ latestVersion = matchParts.captured(2); @@ -3517,7 +3517,7 @@ void MainWindow::on_saveArticle_triggered() QString fileName = view->getTitle().simplified(); // Replace reserved filename characters - QRegularExpression rxName( "[/\\\\\\?\\*:\\|<>]" ); + QRegularExpression rxName( R"([/\\\?\*:\|<>])" ); fileName.replace( rxName, "_" ); fileName += ".html"; @@ -3590,7 +3590,7 @@ void MainWindow::on_saveArticle_triggered() // MDict anchors QRegularExpression anchorLinkRe( - "(<\\s*a\\s+[^>]*\\b(?:name|id)\\b\\s*=\\s*[\"']*g[0-9a-f]{32}_)([0-9a-f]+_)(?=[^\"'])", + R"((<\s*a\s+[^>]*\b(?:name|id)\b\s*=\s*["']*g[0-9a-f]{32}_)([0-9a-f]+_)(?=[^"']))", QRegularExpression::PatternOption::CaseInsensitiveOption|QRegularExpression::UseUnicodePropertiesOption ); html.replace( anchorLinkRe, "\\1" ); diff --git a/mdx.cc b/mdx.cc index 9f2b0f60..9e9125cc 100644 --- a/mdx.cc +++ b/mdx.cc @@ -1283,14 +1283,14 @@ QString MdxDictionary::getCachedFileName( QString filename ) if( n < (qint64)data.size() ) { - gdWarning( "Mdx: file \"%s\" writing error: \"%s\"", fullName.toUtf8().data(), + gdWarning( R"(Mdx: file "%s" writing error: "%s")", fullName.toUtf8().data(), f.errorString().toUtf8().data() ); return QString(); } } else { - gdWarning( "Mdx: file \"%s\" creating error: \"%s\"", fullName.toUtf8().data(), + gdWarning( R"(Mdx: file "%s" creating error: "%s")", fullName.toUtf8().data(), f.errorString().toUtf8().data() ); return QString(); } diff --git a/mediawiki.cc b/mediawiki.cc index bea445d7..6a4c137e 100644 --- a/mediawiki.cc +++ b/mediawiki.cc @@ -395,7 +395,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) wikiUrl.setPath( "/" ); // Update any special index.php pages to be absolute - articleString.replace( QRegularExpression( "", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption ); - QRegularExpression reg2( "\"Play\"/"; + + R"(">Play)"; articleNewString += audio_url; } else @@ -447,7 +447,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) articleString.replace( "#]+" ); + QRegularExpression rxLink( R"(#]+)" ); it = rxLink.globalMatch( articleString ); while( it.hasNext() ) { @@ -458,7 +458,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) } //fix file: url - articleString.replace( QRegularExpression( "isToLanguageRTL() ? "
" : + articleBody.prepend( dictPtr->isToLanguageRTL() ? R"(
)" : "
" ); articleBody.append( "
" ); diff --git a/programs.cc b/programs.cc index a2e9111f..d963623e 100644 --- a/programs.cc +++ b/programs.cc @@ -96,7 +96,7 @@ sptr< Dictionary::DataRequest > ProgramsDictionary::getArticle( result += addAudioLink( ref, getId() ); - result += "
\"Play\"/"; + result += "Play)"; result += "" + Html::escape( wordUtf8 ) + ""; result += ""; diff --git a/sdict.cc b/sdict.cc index e7651b09..76afa53b 100644 --- a/sdict.cc +++ b/sdict.cc @@ -303,7 +303,7 @@ string SdictDictionary::convert( string const & in ) result.replace( QRegularExpression( "<\\s*t\\s*>", QRegularExpression::CaseInsensitiveOption ), - "" ); + R"()" ); result.replace( QRegularExpression( "<\\s*f\\s*>", QRegularExpression::CaseInsensitiveOption ), "" ); @@ -341,7 +341,7 @@ string SdictDictionary::convert( string const & in ) m= end_link_tag.match( result, 0, QRegularExpression::PartialPreferFirstMatch ); result.replace( end, m.captured ().length(), "" ); - result.replace( n, tag_len, QString( ""); + result.replace( n, tag_len, QString( R"("); } // Adjust text direction for lines diff --git a/slob.cc b/slob.cc index 7aa0a14e..8ebc89b6 100644 --- a/slob.cc +++ b/slob.cc @@ -822,16 +822,16 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) // pattern of img and script text.replace( QRegularExpression( "<\\s*(img|script)\\s+([^>]*)src=\"(?!(?:data|https?|ftp):)(|/)([^\"]*)\"" ), - QString( "<\\1 \\2src=\"bres://%1/\\4\"").arg( getId().c_str() ) ); + QString( R"(<\1 \2src="bres://%1/\4")").arg( getId().c_str() ) ); // pattern - text.replace( QRegularExpression( "<\\s*link\\s+([^>]*)href=\"(?!(?:data|https?|ftp):)" ), + text.replace( QRegularExpression( R"(<\s*link\s+([^>]*)href="(?!(?:data|https?|ftp):))" ), QString( ", excluding any known protocols such as http://, mailto:, #(comment) // these links will be translated into local definitions QString anchor; - QRegularExpression rxLink( "<\\s*a\\s+([^>]*)href=\"(?!(?:\\w+://|#|mailto:|tel:))(/|)([^\"]*)\"\\s*(title=\"[^\"]*\")?[^>]*>" ); + QRegularExpression rxLink( R"lit(<\s*a\s+([^>]*)href="(?!(?:\w+://|#|mailto:|tel:))(/|)([^"]*)"\s*(title="[^"]*")?[^>]*>)lit" ); QRegularExpressionMatchIterator it = rxLink.globalMatch( text ); int pos = 0; QString newText; @@ -881,11 +881,11 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) if( !texCgiPath.isEmpty() ) { - QRegularExpression texImage( "<\\s*img\\s+class=\"([^\"]+)\"\\s*([^>]*)alt=\"([^\"]+)\"[^>]*>" ); + QRegularExpression texImage( R"lit(<\s*img\s+class="([^"]+)"\s*([^>]*)alt="([^"]+)"[^>]*>)lit" ); QRegularExpression regFrac( "\\\\[dt]frac" ); - QRegularExpression regSpaces( "\\s+([\\{\\(\\[\\}\\)\\]])" ); + QRegularExpression regSpaces( R"(\s+([\{\(\[\}\)\]]))" ); - QRegExp multReg( "\\*\\{(\\d+)\\}([^\\{]|\\{([^\\}]+)\\})", Qt::CaseSensitive, QRegExp::RegExp2 ); + QRegExp multReg( R"(\*\{(\d+)\}([^\{]|\{([^\}]+)\}))", Qt::CaseSensitive, QRegExp::RegExp2 ); QString arrayDesc( "\\begin{array}{" ); pos = 0; @@ -995,7 +995,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) QProcess::execute( command,QStringList() ); } - QString tag = QString( "

"; + result += R"(

)"; result += i->second.first; result += "

"; result += i->second.second; @@ -1471,7 +1471,7 @@ void SlobArticleRequest::run() for( i = alternateArticles.begin(); i != alternateArticles.end(); ++i ) { - result += "

"; + result += R"(

)"; result += i->second.first; result += "

"; result += i->second.second; diff --git a/sounddir.cc b/sounddir.cc index 6883f8f5..ebd0884c 100644 --- a/sounddir.cc +++ b/sounddir.cc @@ -228,7 +228,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getArticle( wstring const & result += addAudioLink( ref, getId() ); - result += "
\"Play\"/"; + result += "Play)"; result += "" + Html::escape( displayedName ) + ""; result += ""; } @@ -272,7 +272,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getArticle( wstring const & result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; result += "" + Html::escape( displayedName ) + ""; result += ""; } diff --git a/stardict.cc b/stardict.cc index b378b5ad..9d63d964 100644 --- a/stardict.cc +++ b/stardict.cc @@ -417,11 +417,11 @@ private: void translatePW(QString& s){ const int TRANSLATE_TBL_SIZE=5; static PWSyntaxTranslate t[TRANSLATE_TBL_SIZE]={ - PWSyntaxTranslate("&[bB]\\s*\\{([^\\{}&]+)\\}", "\\1"), - PWSyntaxTranslate("&[iI]\\s*\\{([^\\{}&]+)\\}", "\\1"), - PWSyntaxTranslate("&[uU]\\s*\\{([^\\{}&]+)\\}", "\\1"), - PWSyntaxTranslate("&[lL]\\s*\\{([^\\{}&]+)\\}", "\\1"), - PWSyntaxTranslate("&[2]\\s*\\{([^\\{}&]+)\\}", "\\1") + PWSyntaxTranslate(R"(&[bB]\s*\{([^\{}&]+)\})", "\\1"), + PWSyntaxTranslate(R"(&[iI]\s*\{([^\{}&]+)\})", "\\1"), + PWSyntaxTranslate(R"(&[uU]\s*\{([^\{}&]+)\})", "\\1"), + PWSyntaxTranslate(R"(&[lL]\s*\{([^\{}&]+)\})", R"(\1)"), + PWSyntaxTranslate(R"(&[2]\s*\{([^\{}&]+)\})", R"(\1)") }; QString old; @@ -456,10 +456,10 @@ string StardictDictionary::handleResource( char type, char const * resource, siz { QString articleText = QString( "
" ) + QString::fromUtf8( resource, size ) + "
"; - QRegularExpression imgRe( "(<\\s*img\\s+[^>]*src\\s*=\\s*[\"']+)(?!(?:data|https?|ftp):)", + QRegularExpression imgRe( R"((<\s*img\s+[^>]*src\s*=\s*["']+)(?!(?:data|https?|ftp):))", QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ); - QRegularExpression linkRe( "(<\\s*link\\s+[^>]*href\\s*=\\s*[\"']+)(?!(?:data|https?|ftp):)", + QRegularExpression linkRe( R"((<\s*link\s+[^>]*href\s*=\s*["']+)(?!(?:data|https?|ftp):))", QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ); @@ -469,7 +469,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz // Handle links to articles - QRegularExpression linksReg( "]*)href\\s*=\\s*['\"](bword://)?([^'\"]+)['\"]", + QRegularExpression linksReg( R"(]*)href\s*=\s*['"](bword://)?([^'"]+)['"])", QRegularExpression::CaseInsensitiveOption ); @@ -522,7 +522,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz // Handle "audio" tags - QRegularExpression audioRe( "<\\s*audio\\s*src\\s*=\\s*([\"']+)([^\"']+)([\"'])\\s*>(.*)", + QRegularExpression audioRe( R"(<\s*audio\s*src\s*=\s*(["']+)([^"']+)(["'])\s*>(.*))", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption | QRegularExpression::InvertedGreedinessOption ); @@ -549,7 +549,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz newTag += match.captured( 4 ); if( match.captured( 4 ).indexOf( "\"Play\""; + newTag += R"( Play)"; newTag += ""; articleNewText += newTag; @@ -1478,11 +1478,11 @@ void StardictArticleRequest::run() for( i = mainArticles.begin(); i != mainArticles.end(); ++i ) { - result += dict.isFromLanguageRTL() ? "

" : "

"; + result += dict.isFromLanguageRTL() ? R"(

)" : "

"; result += i->second.first; result += "

"; if( dict.isToLanguageRTL() ) - result += "
"; + result += R"(
)"; result += i->second.second; result += cleaner; if( dict.isToLanguageRTL() ) @@ -1491,11 +1491,11 @@ void StardictArticleRequest::run() for( i = alternateArticles.begin(); i != alternateArticles.end(); ++i ) { - result += dict.isFromLanguageRTL() ? "

" : "

"; + result += dict.isFromLanguageRTL() ? R"(

)" : "

"; result += i->second.first; result += "

"; if( dict.isToLanguageRTL() ) - result += "
"; + result += R"(
)"; result += i->second.second; result += cleaner; if( dict.isToLanguageRTL() ) @@ -1750,7 +1750,7 @@ void StardictResourceRequest::run() QString id = QString::fromUtf8( dict.getId().c_str() ); int pos = 0; - QRegularExpression links( "url\\(\\s*(['\"]?)([^'\"]*)(['\"]?)\\s*\\)", + QRegularExpression links( R"(url\(\s*(['"]?)([^'"]*)(['"]?)\s*\))", QRegularExpression::CaseInsensitiveOption ); QString newCSS; diff --git a/voiceengines.cc b/voiceengines.cc index 7a29a439..9d8e326b 100644 --- a/voiceengines.cc +++ b/voiceengines.cc @@ -100,7 +100,7 @@ sptr< Dictionary::DataRequest > VoiceEnginesDictionary::getArticle( string ref = string( "\"" ) + encodedUrl + "\""; result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; result += "" + Html::escape( wordUtf8 ) + ""; result += ""; diff --git a/website.cc b/website.cc index 2c933cae..b98346a8 100644 --- a/website.cc +++ b/website.cc @@ -198,9 +198,9 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) while( !base.isEmpty() && !base.endsWith( "/" ) ) base.chop( 1 ); - QRegularExpression tags( "<\\s*(a|link|img|script)\\s+[^>]*(src|href)\\s*=\\s*['\"][^>]+>", + QRegularExpression tags( R"(<\s*(a|link|img|script)\s+[^>]*(src|href)\s*=\s*['"][^>]+>)", QRegularExpression::CaseInsensitiveOption ); - QRegularExpression links( "\\b(src|href)\\s*=\\s*(['\"])([^'\"]+['\"])", + QRegularExpression links( R"(\b(src|href)\s*=\s*(['"])([^'"]+['"]))", QRegularExpression::CaseInsensitiveOption ); int pos = 0; QString articleNewString; @@ -254,7 +254,7 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) // Redirect CSS links to own handler QString prefix = QString( "bres://" ) + dictPtr->getId().c_str() + "/"; - QRegularExpression linkTags( "(<\\s*link\\s[^>]*rel\\s*=\\s*['\"]stylesheet['\"]\\s+[^>]*href\\s*=\\s*['\"])([^'\"]+)://([^'\"]+['\"][^>]+>)", + QRegularExpression linkTags( R"((<\s*link\s[^>]*rel\s*=\s*['"]stylesheet['"]\s+[^>]*href\s*=\s*['"])([^'"]+)://([^'"]+['"][^>]+>))", QRegularExpression::CaseInsensitiveOption ); pos = 0; it = linkTags.globalMatch( articleString ); diff --git a/zim.cc b/zim.cc index deaeb2a7..2a04319c 100644 --- a/zim.cc +++ b/zim.cc @@ -835,14 +835,14 @@ string ZimDictionary::convert( const string & in ) QString text = QString::fromUtf8( in.c_str() ); // replace background - text.replace( QRegularExpression( "<\\s*body\\s+([^>]*)(background(|-color)):([^;\"]*(;|))" ), + text.replace( QRegularExpression( R"(<\s*body\s+([^>]*)(background(|-color)):([^;"]*(;|)))" ), QString( "]*)src=(\")([^\"]*)\\3" ), // QString( "<\\1 \\2src=\\3bres://%1/").arg( getId().c_str() ) ); - QRegularExpression rxImgScript( "<\\s*(img|script)\\s+([^>]*)src=(\")([^\"]*)\\3" ); + QRegularExpression rxImgScript( R"(<\s*(img|script)\s+([^>]*)src=(")([^"]*)\3)" ); QRegularExpressionMatchIterator it = rxImgScript.globalMatch( text ); int pos = 0; QString newText; @@ -863,7 +863,7 @@ string ZimDictionary::convert( const string & in ) if( !url.isEmpty() && !url.startsWith( "//" ) && !url.startsWith( "http://" ) && !url.startsWith( "https://" ) ) { //<\\1 \\2src=\\3bres://%1/ - url.remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption)); + url.remove(QRegularExpression(R"(^\.*\/[A-Z]\/)", QRegularExpression::CaseInsensitiveOption)); replacedLink = QString( "<%1 %2 src=\"bres://%3/%4\"" ).arg( list[ 1 ], list[ 2 ], QString::fromStdString( getId() ), url ); } @@ -879,23 +879,23 @@ string ZimDictionary::convert( const string & in ) // Fix links without '"' - text.replace( QRegularExpression( "href=(\\.\\.|)/([^\\s>]+)" ), - QString( "href=\"\\1/\\2\"" ) ); + text.replace( QRegularExpression( R"(href=(\.\.|)/([^\s>]+))" ), + QString( R"(href="\1/\2")" ) ); // pattern - text.replace( QRegularExpression( "<\\s*link\\s+([^>]*)href=\"(\\.\\.|)/" ), + text.replace( QRegularExpression( R"(<\s*link\s+([^>]*)href="(\.\.|)/)" ), QString( " series links // excluding those keywords that have ":" in it QString urlWiki = "\"http(s|)://en\\.(wiki(pedia|books|news|quote|source|voyage|versity)|wiktionary)\\.(org|com)/wiki/([^:\"]*)\""; - text.replace( QRegularExpression( "<\\s*a\\s+(class=\"external\"\\s+|)href=" + urlWiki ), - QString( ", excluding any known protocols such as http://, mailto:, #(comment) // these links will be translated into local definitions // - QRegularExpression rxLink( "<\\s*(?:a|meta)\\s+([^>]*)(?:href|url)=\"?(?!(?:\\w+://|#|mailto:|tel:))()([^\"]*)\"\\s*(title=\"[^\"]*\")?[^>]*>" ); + QRegularExpression rxLink( R"lit(<\s*(?:a|meta)\s+([^>]*)(?:href|url)="?(?!(?:\w+://|#|mailto:|tel:))()([^"]*)"\s*(title="[^"]*")?[^>]*>)lit" ); it = rxLink.globalMatch( text ); pos = 0; while( it.hasNext() ) @@ -944,7 +944,7 @@ string ZimDictionary::convert( const string & in ) // Occasionally words needs to be displayed in vertical, but
were changed to somewhere // proper style:
N
e
o
p
t
e
r
a
- QRegularExpression rxBR( "(]*>)\\s*((\\w\\s*<br(\\\\|/|)>\\s*)+\\w)\\s*", + QRegularExpression rxBR( R"((]*>)\s*((\w\s*<br(\\|/|)>\s*)+\w)\s*)", QRegularExpression::UseUnicodePropertiesOption ); pos = 0; QRegularExpressionMatchIterator it2 = rxBR.globalMatch( text ); @@ -1520,7 +1520,7 @@ void ZimResourceRequest::run() sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name ) { - auto formatedName = QString::fromStdString(name).remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption)); + auto formatedName = QString::fromStdString(name).remove(QRegularExpression(R"(^\.*\/[A-Z]\/)", QRegularExpression::CaseInsensitiveOption)); return std::make_shared( *this, formatedName.toStdString() ); } diff --git a/zipsounds.cc b/zipsounds.cc index 3c39c03a..8a4e086a 100644 --- a/zipsounds.cc +++ b/zipsounds.cc @@ -279,7 +279,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getArticle( wstring const & result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; result += "" + Html::escape( displayedName ) + ""; result += ""; } @@ -325,7 +325,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getArticle( wstring const & result += addAudioLink( ref, getId() ); - result += "\"Play\"/"; + result += "Play)"; result += "" + Html::escape( displayedName ) + ""; result += ""; }