How do I decode `mailto:` link to more readable form?

0

Is there a simple tool that just dumps the content of a mailto link to console?

$ decode_mailto 'mailto:a@b.c?subject=qqq&body=www%20eee&'
To: a@b.c
Subject: qqq

www eee

Vi.

Posted 2014-12-12T16:07:18.293

Reputation: 13 705

Question was closed 2014-12-15T15:29:15.247

Why not just click on it, and it will appear in your e-mail client, correctly formatted? You don't have to send it. – AFH – 2014-12-12T16:18:45.640

The mailto: link may be generated outside normal desktop environment where e-mail client may work. – Vi. – 2014-12-12T16:20:56.227

Answers

3

$ cat decode_mailto 
#!/bin/bash
perl -lpe 's/%([0-9a-fA-F]{2})/chr(hex($1))/eg;s/mailto:/To: /g;s/subject=/Subject: /g;s/body=/\n/g;s/[&?]/\n/g'

$ chmod 755 decode_mailto 

$ echo 'mailto:a@b.c?subject=qqq&body=www%20eee&' | ./decode_mailto
To: a@b.c
Subject: qqq

www eee


$ 

Hannu

Posted 2014-12-12T16:07:18.293

Reputation: 4 950

Update for actual HEX-code, not just bare DEC-numbers (mindlapse). – Hannu – 2014-12-15T16:46:22.307