aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-08-02 10:53:32 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-08-02 10:53:32 +1200
commitc73f92c337558e8579f9905f6e90b661baa67699 (patch)
tree35eb1c0f84c3fde867d9f2ba36aa9cfbc5dcca5f
parentf4731a8406b67120049985de959da0688fe3c108 (diff)
downloaddotfiles-c73f92c337558e8579f9905f6e90b661baa67699.tar.gz
Add defang(1df)
><tejr> I learned the word "defang" today as applied to URLs ><tejr> I knew about the practice but not what it was called ><tejr> Now I am writing a little script to do it for me ><russm> tejr: pip install defang ? ><tejr> Why you gotta be like that, russm ><tejr> Let me have my three-line sed script
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rw-r--r--README.md1
-rw-r--r--bin/defang.sed4
-rw-r--r--man/man1/defang.1df17
5 files changed, 24 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 9e71ad86..a6b9e0e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@
/bin/d2u
/bin/dam
/bin/ddup
+/bin/defang
/bin/dfv
/bin/dfv.m4
/bin/dfv.sh
diff --git a/Makefile b/Makefile
index e6fd8d70..58c077f9 100644
--- a/Makefile
+++ b/Makefile
@@ -114,6 +114,7 @@ BINS = bin/ap \
bin/dam \
bin/d2u \
bin/ddup \
+ bin/defang \
bin/dfv \
bin/dmp \
bin/dub \
diff --git a/README.md b/README.md
index bb095c3c..6c53c211 100644
--- a/README.md
+++ b/README.md
@@ -505,6 +505,7 @@ Installed by the `install-bin` target:
input.
* `dam(1df)` buffers all its input before emitting it as output.
* `ddup(1df)` removes duplicate lines from unsorted input.
+* `defang(1df)` prevents dangerous URLs from being made into clickable links.
* `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X CLIPBOARD.
* `dub(1df)` lists the biggest entries in a directory.
* `edda(1df)` provides a means to run `ed(1)` over a set of files preserving
diff --git a/bin/defang.sed b/bin/defang.sed
new file mode 100644
index 00000000..0a9a314e
--- /dev/null
+++ b/bin/defang.sed
@@ -0,0 +1,4 @@
+# Escape a dangerous URL to discourage it from being made into a link
+s|^http|hxxp|
+s|://|[&]|
+s|\.|[&]|g
diff --git a/man/man1/defang.1df b/man/man1/defang.1df
new file mode 100644
index 00000000..1d99cd14
--- /dev/null
+++ b/man/man1/defang.1df
@@ -0,0 +1,17 @@
+.TH DEFANG 1df "August 2019" "Manual page for defang"
+.SH NAME
+.B defang
+\- butcher dangerous URLs to stop them being made clickable
+.SH USAGE
+.B defang [FILE1 [FILE2 ...]]
+.br
+.B defang
+< FILE
+.br
+printf 'http://pwn3d.badguys.icu/h4ck/0x_ph1sh.html' |
+.B defang
+.SH DESCRIPTION
+Manipulates URLs on each line of input in such a way that they're unlikely to
+be made into clickable links by tools that try to make dynamic HTML links.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>