Skip to content

Commit e4a6b18

Browse files
committed
FIX(client,Markdown): Do not prefix local file paths in references with "http"
Enables the use of references with file URIs by not prefixing the protocol "http" in either case where the reference value already starts with "http" or "file".
1 parent 8a6ff17 commit e4a6b18

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/mumble/Markdown.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,22 +455,22 @@ bool processMarkdownReferenceDefinition(Markdown::Items &items) {
455455
QLatin1String("\n*\\h{,3}\\[([^\\]\n]+)\\]:\\h(?:<(.+?)>|([^\\h\n]+))"
456456
"(?:\\h(?:\"([^\"\n]+)\"|'([^'\n]+)'|\\(([^\\)\n]+)\\)))?(?:\\h*\n)*\\h*$"),
457457
QRegularExpression::MultilineOption);
458-
return regexMatchAndReplace(items, regex, "",
459-
[&items](const QRegularExpressionMatch &match, const char *contentWrapper) {
460-
QString reference = match.captured(1).toHtmlEscaped();
461-
QString url = findFirstMatchedGroup(match, 2, 3).toHtmlEscaped();
462-
QString title = findFirstMatchedGroup(match, 4, 6).toHtmlEscaped();
458+
return regexMatchAndReplace(
459+
items, regex, "", [&items](const QRegularExpressionMatch &match, const char *contentWrapper) {
460+
QString reference = match.captured(1).toHtmlEscaped();
461+
QString url = findFirstMatchedGroup(match, 2, 3).toHtmlEscaped();
462+
QString title = findFirstMatchedGroup(match, 4, 6).toHtmlEscaped();
463463

464-
if (!url.startsWith("http", Qt::CaseInsensitive)) {
465-
url.prepend("http://");
466-
}
464+
if (!url.startsWith("http", Qt::CaseInsensitive) && !url.startsWith("file", Qt::CaseInsensitive)) {
465+
url.prepend("http://");
466+
}
467467

468-
QHash< QString, std::tuple< QString, QString > > &references = items.references;
469-
if (!references.contains(reference)) {
470-
references[reference] = { unescapeURL(url), title };
471-
}
472-
return QLatin1String(contentWrapper);
473-
});
468+
QHash< QString, std::tuple< QString, QString > > &references = items.references;
469+
if (!references.contains(reference)) {
470+
references[reference] = { unescapeURL(url), title };
471+
}
472+
return QLatin1String(contentWrapper);
473+
});
474474
}
475475

476476
/// Tries to find and insert queued Markdown references, replacing each placeholder and name

0 commit comments

Comments
 (0)