Commit e60e71b7 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Kurt Hindenburg
Browse files

url filter: remove ending apostrophe

When URLs were inside single quotes, we would include the ending quote
in the parsed URL.  To avoid that, remove a final apostrophe in a URL
when creating the hotspot.

Test:
'https://en.wikipedia.org/wiki/Earth's_rotation'

BUG: 458996
(cherry picked from commit f063ade5)
parent 8e4028f0
......@@ -94,5 +94,21 @@ UrlFilter::UrlFilter()
QSharedPointer<HotSpot> UrlFilter::newHotSpot(int startLine, int startColumn, int endLine, int endColumn, const QStringList &capturedTexts)
{
return QSharedPointer<HotSpot>(new UrlFilterHotSpot(startLine, startColumn, endLine, endColumn, capturedTexts));
QStringList texts{};
// remove final single quote
// we want URLs in single quotes like the following to work correctly:
// 'https://en.wikipedia.org/wiki/Earth's_rotation'
for (QString s : capturedTexts) {
QString str{s};
if (s.right(1) == QLatin1String("'")) {
s.chop(1);
}
texts << s;
}
if (capturedTexts[0].right(1) == QLatin1String("'")) {
endColumn--;
}
return QSharedPointer<HotSpot>(new UrlFilterHotSpot(startLine, startColumn, endLine, endColumn, texts));
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment