ext/markdown/autolink.c in github-markdown-0.6.5 vs ext/markdown/autolink.c in github-markdown-0.6.6

- old
+ new

@@ -133,20 +133,24 @@ } static size_t check_domain(uint8_t *data, size_t size, int allow_short) { - size_t i, np = 0; + size_t i, np = 0, uscore1 = 0, uscore2 = 0; - if (!isalnum(data[0])) - return 0; - - for (i = 1; i < size - 1; ++i) { - if (data[i] == '.') np++; + for (i = 1; i < size - 1; i++) { + if (data[i] == '_') uscore2++; + else if (data[i] == '.') { + uscore1 = uscore2; + uscore2 = 0; + np++; + } else if (!isalnum(data[i]) && data[i] != '-') break; } + if (uscore1 > 0 || uscore2 > 0) return 0; + if (allow_short) { /* We don't need a valid domain in the strict sense (with * least one dot; so just make sure it's composed of valid * domain characters and return the length of the the valid * sequence. */ @@ -167,10 +171,10 @@ size_t size, unsigned int flags) { size_t link_end; - if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1])) + if (max_rewind > 0 && data[-1] != '(' && data[-1] != '[' && !isspace(data[-1])) return 0; if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0) return 0;