termite: Add patch to avoid matching trailing punctuation in URLs

Patch based on:
https://github.com/thestinger/termite/pull/516

While this might "break" some URL's in the wild,
in return this fixes matching of URL's in Nix code.
Without this patch the trailing semicolon is included as part of the
URL, which creates invalid URL's for nearly all meta.homepage values.

authored by Will Dietz and committed by Jan Tojnar c433fef5 8e6d5639

+30
+3
pkgs/applications/misc/termite/default.nix
··· 13 13 sha256 = "02cn70ygl93ghhkhs3xdxn5b1yadc255v3yp8cmhhyzsv5027hvj"; 14 14 }; 15 15 16 + # https://github.com/thestinger/termite/pull/516 17 + patches = [ ./url_regexp_trailing.patch ]; 18 + 16 19 postPatch = "sed '1i#include <math.h>' -i termite.cc"; 17 20 18 21 makeFlags = [ "VERSION=v${version}" "PREFIX=" "DESTDIR=$(out)" ];
+27
pkgs/applications/misc/termite/url_regexp_trailing.patch
··· 1 + Based on https://github.com/thestinger/termite/pull/516 2 + Modified to apply to v13 3 + 4 + From 65a454ffa8e681f3f14729cba7c42e1570a85e8a Mon Sep 17 00:00:00 2001 5 + From: Paul Baecher <pbaecher@gmail.com> 6 + Date: Thu, 7 Sep 2017 22:58:51 +0200 7 + Subject: [PATCH] Do not match punctuation at the end of URLs 8 + 9 + Punctuation at the end of URLs is most likely part of natural language 10 + or markup (for example in Markdown). Do not match it as part of the URL. 11 + --- 12 + url_regex.hh | 2 +- 13 + 1 file changed, 1 insertion(+), 1 deletion(-) 14 + 15 + diff --git a/url_regex.hh b/url_regex.hh 16 + index 2ec6be8..3039b53 100644 17 + --- a/url_regex.hh 18 + +++ b/url_regex.hh 19 + @@ -9,7 +9,7 @@ 20 + #define PORT "(?:\\:[[:digit:]]{1,5})?" 21 + #define SCHEME "(?:[[:alpha:]][+-.[:alnum:]]*:)" 22 + #define USERPASS USERCHARS_CLASS "+(?:\\:" PASSCHARS_CLASS "+)?" 23 + -#define URLPATH "(?:/[[:alnum:]\\Q-_.!~*'();/?:@&=+$,#%\\E]*)?" 24 + +#define URLPATH "(?:/[[:alnum:]\\Q-_.!~*'();/?:@&=+$,#%\\E]*(?<![\\Q.,:;()!?\\E]))?" 25 + 26 + const char * const url_regex = SCHEME "//(?:" USERPASS "\\@)?" HOST PORT URLPATH; 27 +