[viewvc-dev] [PATCH] Fix issue #407

Senthil Kumaran S <[email protected]> Wed, 21 Oct 2009 18:17:45 +0530
Newsgroups gmane.comp.version-control.cvs.viewcvs.devel
Organization CollabNet Software Pvt. Ltd
Message-ID <[email protected]>
Hi,

I am attaching a patch in order to fix issue #407.

[[[

Fix issue #407.



* lib/viewvc.py

  (get_itemprops): Add regular expression to identify a URL in the

   property value and use that to substitute it with a link.



Patch by: Senthil Kumaran S <[email protected]>

]]]

Thank You.
-- 
Senthil Kumaran S
http://www.stylesen.org/

------------------------------------------------------
http://viewvc.tigris.org/ds/viewMessage.do?dsForumId=4251&dsMessageId=2409764

To unsubscribe from this discussion, e-mail: [[email protected]].
fix_issue407.patch (text/x-diff, 794 B)
[[[
Fix issue #407.

* lib/viewvc.py
  (get_itemprops): Add regular expression to identify a URL in the
   property value and use that to substitute it with a link.

Patch by: Senthil Kumaran S <[email protected]>
]]]

Index: lib/viewvc.py
===================================================================
--- lib/viewvc.py	(revision 2274)
+++ lib/viewvc.py	(working copy)
@@ -1623,8 +1623,10 @@
   propnames.sort()
   props = []
   has_binary_props = 0
+  _re_url = re.compile(r'''(?x)((http|https)://(\w+[:.]?){2,}(/?|[^ \n\r"]+[\w
+                           /])(?=[\s\.,>)'"\]]))''')
   for name in propnames:
-    value = itemprops[name]
+    value = _re_url.sub(r'<a href="\1">\1</a>', itemprops[name])
     undisplayable = ezt.boolean(0)
     # skip non-utf8 property names
     try: