Skip to content
Browse files

Accept 127.0.0.1 (and other ip numbers) as links too.

svn path=/plone.intelligenttext/trunk/; revision=18263
  • Loading branch information...
1 parent 1373d99 commit dead5218d9c656748a05ffd69e78e5abdaabbc1e @mauritsvanrees mauritsvanrees committed
Showing with 11 additions and 2 deletions.
  1. +10 −0 plone/intelligenttext/README.txt
  2. +1 −2 plone/intelligenttext/transforms.py
View
10 plone/intelligenttext/README.txt
@@ -126,6 +126,16 @@ localhost should be good.
>>> convertWebIntelligentPlainTextToHtml(url)
'<a href="http://localhost:8080/" rel="nofollow">http://localhost:8080/</a>'
+Check ip numbers too while we are at it.
+
+ >>> url = "http://127.0.0.1:8080/"
+ >>> convertWebIntelligentPlainTextToHtml(url)
+ '<a href="http://127.0.0.1:8080/" rel="nofollow">http://127.0.0.1:8080/</a>'
+ >>> convertWebIntelligentPlainTextToHtml("http://255.255.255.255")
+ '<a href="http://255.255.255.255" rel="nofollow">http://255.255.255.255</a>'
+ >>> convertWebIntelligentPlainTextToHtml("http://0.0.0.0")
+ '<a href="http://0.0.0.0" rel="nofollow">http://0.0.0.0</a>'
+
Unicode should be fine too.
>>> text = u"Línk tö http://foo.ni"
View
3 plone/intelligenttext/transforms.py
@@ -22,8 +22,7 @@ def abbreviateUrl(url, max = 60, ellipsis = "[&hellip;]"):
return protocol + list[0] +"/" +ellipsis + "/" + list[-1]
- #urlRegexp = re.compile(r'((?:ftp|https?)://(localhost|([12]?[0-9]{1,2}.){3}([12]?[0-9]{1,2})|(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z]))\b(?::\d+)?(?:\/[^"\'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^"\'<>()\[\]{}\s\x7f-\xff]+)*)?)', re.I|re.S|re.U)
- urlRegexp = re.compile(r'((?:ftp|https?)://(localhost|(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z]))\b(?::\d+)?(?:\/[^"\'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^"\'<>()\[\]{}\s\x7f-\xff]+)*)?)', re.I|re.S|re.U)
+ urlRegexp = re.compile(r'((?:ftp|https?)://(localhost|([12]?[0-9]{1,2}.){3}([12]?[0-9]{1,2})|(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z]))\b(?::\d+)?(?:\/[^"\'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^"\'<>()\[\]{}\s\x7f-\xff]+)*)?)', re.I|re.S|re.U)
emailRegexp = re.compile(r'["=]?(\b[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}\b)', re.I|re.S|re.U)
indentRegexp = re.compile(r'^(\s+)', re.M|re.U)

0 comments on commit dead521

Please sign in to comment.
Something went wrong with that request. Please try again.