]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Fix edge case with URL definitions
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Tue, 14 Mar 2017 21:43:03 +0000 (17:43 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Tue, 14 Mar 2017 21:43:03 +0000 (17:43 -0400)
Sources/libMultiMarkdown/writer.c

index 7aa4bff5c41acf90f5cd4a052f98f2c2f6827f7e..69261b3b8b6ea205dd37f8f42e62473b50748ae4 100644 (file)
@@ -851,12 +851,15 @@ char * destination_accept(const char * source, token ** remainder, bool validate
                        // Grab destination string
                        url = my_strndup(&source[start], scan_len);
 
-                       // Advance remainder
-                       while ((*remainder)->start < start + scan_len)
+                       // Advance remainder to end of destination
+                       while ((*remainder)->next &&
+                                  (*remainder)->next->start < start + scan_len) {
                                *remainder = (*remainder)->next;
+                       }
 
-
-                       t = (*remainder)->prev;
+                       t = (*remainder);       // We need to remember this for below
+                       // Move remainder beyond destination
+                       *remainder = (*remainder)->next;
 
                        // Is there a space in a URL concatenated with a title or attribute?
                        // e.g. [foo]: http://foo.bar/ class="foo"