mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Escape regexp meta-characters in search strings
This resolves the regression where Highlight Callsign UDP messages fail when the callsign contains a '+' character.
This commit is contained in:
parent
c30c3ce4c8
commit
a8115a9000
@ -553,7 +553,14 @@ void DisplayText::highlight_callsign (QString const& callsign, QColor const& bg,
|
||||
{
|
||||
return;
|
||||
}
|
||||
QRegularExpression target {QString {"<?"} + callsign + QString {">?"}, QRegularExpression::DontCaptureOption};
|
||||
auto regexp = callsign;
|
||||
// allow for hashed callsigns and escape any regexp metacharacters
|
||||
QRegularExpression target {QString {"<?"}
|
||||
+ regexp.replace (QLatin1Char {'+'}, QLatin1String {"\\+"})
|
||||
.replace (QLatin1Char {'.'}, QLatin1String {"\\."})
|
||||
.replace (QLatin1Char {'?'}, QLatin1String {"\\?"})
|
||||
+ QString {">?"}
|
||||
, QRegularExpression::DontCaptureOption};
|
||||
QTextCharFormat old_format {currentCharFormat ()};
|
||||
QTextCursor cursor {document ()};
|
||||
if (last_period_only)
|
||||
|
Loading…
Reference in New Issue
Block a user