Some more improvements for the tags/nicknames/groups regexp's
[debian/pino.git] / debian / patches / 003_improve-regex.diff
1 Description: Fix regex for search/tags
2 Author: Julien Valroff <julien@kirya.net>
3 Bug: http://code.google.com/p/pino-twitter/issues/detail?id=141
4 Forwarded: yes
5
6 --- a/src/template.vala
7 +++ b/src/template.vala
8 @@ -59,10 +59,10 @@
9                 reload();
10                 
11                 //compile regex
12 -               nicks = new Regex("(^|\\s)@([A-Za-z0-9_]+)");
13 -               tags = new Regex("((^|\\s)\\#[A-Za-z0-9_\\p{Latin}\\p{Greek}]+)");
14 -               groups = new Regex("(^|\\s)!([A-Za-z0-9_]+)"); //for identi.ca groups
15 -               urls = new Regex("((http|https|ftp)://([\\S]+))"); //need something better
16 +               nicks = new Regex("(^|\\s|['\"+&!/\\(-])@([A-Za-z0-9_]+)");
17 +               tags = new Regex("(^|\\s|['\"+&!/\\(-])#([A-Za-z0-9_.-\\p{Latin}\\p{Greek}]+)");
18 +               groups = new Regex("(^|\\s|['\"+&!/\\(-])!([A-Za-z0-9_]+)"); //for identi.ca groups
19 +               urls = new Regex("((https?|ftp)://([A-Za-z0-9+&@#/%?=~_|!:,.;-]*)([A-Za-z0-9+&@#/%=~_|$]))"); // still needs to be improved for urls containing () such as wikipedia's
20                 
21                 // characters must be cleared to know direction of text
22                 clear_notice = new Regex("[: \n\t\r♻♺]+|@[^ ]+");
23 @@ -400,7 +400,7 @@
24                 }
25                 
26                 result = nicks.replace(result, -1, 0, "\\1@<a class='re_nick' href='userinfo://\\2'>\\2</a>");
27 -               result = tags.replace(result, -1, 0, "<a class='tags' href='%s\\1'>\\1</a>".printf(search_url));
28 +               result = tags.replace(result, -1, 0, "\\1#<a class='tags' href='%s\\2'>\\2</a>".printf(search_url));
29                 
30                 if(service == "identi.ca") //for identi.ca only
31                         result = groups.replace(result, -1, 0, "\\1!<a class='tags' href='http://identi.ca/group/\\2'>\\2</a>");