From 2ab65d300ababe0eed36e46acc8cf3199f683d48 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Fri, 17 Apr 2020 16:17:30 +0200 Subject: [PATCH] Fix #+LINK: file xyz edge case if we define a custom LINK for file we run into index problems bc it's trimmed before already - this fixes that. Shouldn't ever happen but whatever, fuzzing found it. --- org/html_writer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/html_writer.go b/org/html_writer.go index 6d77b7c..e0290b1 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -339,7 +339,7 @@ func (w *HTMLWriter) WriteRegularLink(l RegularLink) { url = url[len("file:"):] } if prefix := w.document.Links[l.Protocol]; prefix != "" { - url = html.EscapeString(prefix) + url[len(l.Protocol)+1:] + url = html.EscapeString(prefix) + strings.TrimPrefix(url, l.Protocol+":") } description := url if l.Description != nil {