From b19632f49663e1b1e9e4a1b93e1f018071f76c73 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 19 Jan 2024 15:48:39 +0100 Subject: [PATCH] improve magnet link regex pattern --- Makefile | 2 ++ st-urlhandler | 2 +- st-weechatlinks | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 02045f0..cbd5b21 100644 --- a/Makefile +++ b/Makefile @@ -44,9 +44,11 @@ install: st cp -f st $(DESTDIR)$(PREFIX)/bin cp -f st-copyout $(DESTDIR)$(PREFIX)/bin cp -f st-urlhandler $(DESTDIR)$(PREFIX)/bin + cp -f st-weechatlinks $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/st chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout chmod 755 $(DESTDIR)$(PREFIX)/bin/st-urlhandler + chmod 755 $(DESTDIR)$(PREFIX)/bin/st-weechatlinks mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1 diff --git a/st-urlhandler b/st-urlhandler index 0eb4586..8b7da4f 100755 --- a/st-urlhandler +++ b/st-urlhandler @@ -1,6 +1,6 @@ #!/bin/sh -urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)" +urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9&=%-\.]*)" urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars: grep -aEo "$urlregex" | # grep only urls as defined above. diff --git a/st-weechatlinks b/st-weechatlinks index d8f720d..bf94814 100755 --- a/st-weechatlinks +++ b/st-weechatlinks @@ -5,7 +5,7 @@ buffer="$(cat)" #URLs: -urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\!\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)" +urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\!\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9&=%-\.]*)" urls="$(echo "$buffer" | sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars: grep -aEo "$urlregex" | # grep only urls as defined above.