improved url regex

This commit is contained in:
Daniel Micay 2012-07-20 10:05:46 -04:00
parent c4a2ee4840
commit 4940cf4a75
2 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,5 @@
* tab and shift-tab bindings for completion * tab and shift-tab bindings for completion
* better url matching regex * improved matching capabilities (not just urls)
* hint mode overlay for urls (like elinks/vimperator/pentadactyl) * hint mode overlay for urls (like elinks/vimperator/pentadactyl)
* scrollback search needs to be improved upstream [1]_ * scrollback search needs to be improved upstream [1]_
* expose keybindings in ``termite.cfg`` * expose keybindings in ``termite.cfg``

View File

@ -14,7 +14,19 @@
#define CSI "\x1b[" #define CSI "\x1b["
static const char * const url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+()]*"; #define USERCHARS "-[:alnum:]"
#define USERCHARS_CLASS "[" USERCHARS "]"
#define PASSCHARS_CLASS "[-[:alnum:]\\Q,?;.:/!%$^*&~\"#'\\E]"
#define HOSTCHARS_CLASS "[-[:alnum:]]"
#define HOST HOSTCHARS_CLASS "+(\\." HOSTCHARS_CLASS "+)*"
#define PORT "(?:\\:[[:digit:]]{1,5})?"
#define PATHCHARS_CLASS "[-[:alnum:]\\Q_$.+!*,;@&=?/~#%\\E]"
#define PATHTERM_CLASS "[^\\Q]'.}>) \t\r\n,\"\\E]"
#define SCHEME "(?:news:|telnet:|nntp:|file:\\/|https?:|ftps?:|sftp:|webcal:)"
#define USERPASS USERCHARS_CLASS "+(?:" PASSCHARS_CLASS "+)?"
#define URLPATH "(?:(/" PATHCHARS_CLASS "+(?:[(]" PATHCHARS_CLASS "*[)])*" PATHCHARS_CLASS"*)*"PATHTERM_CLASS ")?"
static const char * const url_regex = SCHEME "//(?:" USERPASS "\\@)?" HOST PORT URLPATH;
typedef enum overlay_mode { typedef enum overlay_mode {
OVERLAY_HIDDEN = 0, OVERLAY_HIDDEN = 0,