Skip to content

Commit c433fef

Browse files
dtzWilljtojnar
authored andcommittedDec 20, 2017
termite: Add patch to avoid matching trailing punctuation in URLs
Patch based on: thestinger/termite#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.
1 parent 8e6d563 commit c433fef

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
 

‎pkgs/applications/misc/termite/default.nix

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ let
1313
sha256 = "02cn70ygl93ghhkhs3xdxn5b1yadc255v3yp8cmhhyzsv5027hvj";
1414
};
1515

16+
# https://github.com/thestinger/termite/pull/516
17+
patches = [ ./url_regexp_trailing.patch ];
18+
1619
postPatch = "sed '1i#include <math.h>' -i termite.cc";
1720

1821
makeFlags = [ "VERSION=v${version}" "PREFIX=" "DESTDIR=$(out)" ];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+

0 commit comments

Comments
 (0)
Please sign in to comment.