--- a/trac/tickets.go Mon Aug 17 22:44:53 2020 -0500
+++ b/trac/tickets.go Tue Aug 18 01:33:03 2020 -0500
@@ -121,6 +121,9 @@
debianBugRegex = regexp.MustCompile(`\[DebianBug:(\d+)(?:\s([^]]+))?\]`)
gnomeBugRegex = regexp.MustCompile(`\[GnomeBug:(\d+)(?:\s([^]]+))?\]`)
+ inlineImageRegex = regexp.MustCompile(`\[\[Image\(([^)]+)\)\]\]`) func convertLinks(text string) string {
@@ -181,8 +184,12 @@
// replace any ticket link references
comment = ticketLinkRegex.ReplaceAllString(comment, projectID+"-$1$2")
+ // clean up some custom links comment = convertLinks(comment)
+ comment = inlineImageRegex.ReplaceAllString(comment, "![]($1)") --- a/youtrack/attachment.go Mon Aug 17 22:44:53 2020 -0500
+++ b/youtrack/attachment.go Tue Aug 18 01:33:03 2020 -0500
@@ -175,6 +175,8 @@
+// extractAttachments will look for any inline images to external pages, and if +// found, will grab the content and add it as an attachment. func extractAttachments(issue int, author, message string, created time.Time) (string, []*Attachment, error) {
pattern := `!\[(.*?)\]\((.+?)(\s+["'].*?["'])?\)`
regex := regexp.MustCompile(pattern)
@@ -201,11 +203,13 @@
resp, err := http.Get(uri)
- return "", attachments, err
+ // these images could be links to anywhere, which can and will be + // broken, so we just ignore errors. if resp.StatusCode != http.StatusOK {
- return "", attachments, fmt.Errorf("unexpected status code %d", resp.StatusCode)
attachment := NewAttachment(issue, author, created)