Skip to content

Commit 3718a0a

Browse files
committed
Support ' and () in url
since they are valid and can be found in url (ex: kibana), support them. Signed-off-by: Gaetan Semet <[email protected]>
1 parent f440b47 commit 3718a0a

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

guake/globals.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ def is_run_from_git_workdir():
7272
# TODO this is not as fancy as as it could be
7373
# pylint: disable=anomalous-backslash-in-string
7474
TERMINAL_MATCH_TAGS = ('schema', 'http', 'https', 'email', 'ftp')
75+
# Beware this is a PRCE (Perl) regular expression, not a Python one!
76+
# Edit: use regex101.com with PCRE syntax
7577
TERMINAL_MATCH_EXPRS = [
76-
"(news:|telnet:|nntp:|file:\/|https?:|ftps?:|webcal:)\/\/"
77-
"([-[:alnum:]]+(:[-[:alnum:],?;.:\/!%$^*&~\"#']+)?\@)?[-[:alnum:]]+"
78-
"(\.[-[:alnum:]]+)*(:[0-9]{1,5})?(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#%]*[^]'.>) \t\r\n,\\\"])?",
78+
"(news:|telnet:|nntp:|file:\/|https?:|ftps?:|webcal:)\/\/([-[:alnum:]]+"
79+
"(:[-[:alnum:],?;.:\/!%$^\*&~\"#']+)?\@)?[-[:alnum:]]+(\.[-[:alnum:]]+)*"
80+
"(:[0-9]{1,5})?(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#'%]*[^].> \t\r\n,\\\"])?",
7981
"(www|ftp)[-[:alnum:]]*\.[-[:alnum:]]+(\.[-[:alnum:]]+)*(:[0-9]{1,5})?"
8082
"(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#%]*[^]'.>) \t\r\n,\\\"])?",
8183
"(mailto:)?[-[:alnum:]][-[:alnum:].]*@[-[:alnum:]]+\.[-[:alnum:]]+(\\.[-[:alnum:]]+)*"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fixes:
2+
- |
3+
URL with ``'`` (simple quote) and ``()`` (parenthesis) are now captured by hyperlink matcher.
4+
This may causes some issues with log and so that use parenthesis *around* hyperlinks,
5+
but since parenthesis and quotes are valid characters inside a URL, like for instance
6+
URL created by Kibana, they deserve the right to be shown as proper url in Guake.
7+
8+
User can still select the URL in the terminal if he wishes to capture the exact url, before
9+
doing a Ctrl+click or a right click.
10+
11+
For developers, it is advised to end the URL with a character that cannot be used in URL, such
12+
as space, tab, new line. Ending with a dot (``.``) or a comma (``,``) will not be seen as part
13+
of the URL by Guake, so most logs and traces that adds a dot or a comma at the end of the URL
14+
might still work.
15+
16+
known_issues:
17+
- Multiline url are sometimes not handled correctly.

scripts/weird_urls.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
4+
#!/bin/bash
5+
echo "blab blab la : http://mykibana.server/app/kibana#/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-24h,mode:quick,to:now))&_a=(columns:!(levelname,syslog_message,extra.flat),interval:auto,query:(language:lucene,query:'uuid:%22076a4d47-4af5-4808-ab7d-1d5e6983e7c6%22'),sort:!('@timestamp',asc))"

0 commit comments

Comments
 (0)