changeset 598:40db54427950

urllog: Clean up regexp statements.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 03 Feb 2021 13:37:10 +0200
parents 6997201c7b71
children 76d19fa28753
files urllog.tcl
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/urllog.tcl	Wed Feb 03 13:36:43 2021 +0200
+++ b/urllog.tcl	Wed Feb 03 13:37:10 2021 +0200
@@ -276,11 +276,11 @@
   upvar $urlMHostName urlHostName
 
   ### Hack for removing parenthesis around an URL
-  if {[regexp {^\((.+)\)$} $urlStr urlMatch urlClean]} {
+  if {[regexp {^\((.+)\)$} $urlStr -> urlClean]} {
     set urlStr $urlClean
   }
 
-  if {[regexp {^\[(.+)\]$} $urlStr urlMatch urlClean]} {
+  if {[regexp {^\[(.+)\]$} $urlStr -> urlClean]} {
     set urlStr $urlClean
   }
 
@@ -295,7 +295,7 @@
   }
 
   ### Handle URLs that have an IPv4-address
-  if {[regexp "(\[a-z\]+)://(\[0-9\]{1,3})\\.(\[0-9\]{1,3})\\.(\[0-9\]{1,3})\\.(\[0-9\]{1,3})" $urlStr urlMatch urlProto ni1 ni2 ni3 ni4]} {
+  if {[regexp "(\[a-z\]+)://(\[0-9\]{1,3})\\.(\[0-9\]{1,3})\\.(\[0-9\]{1,3})\\.(\[0-9\]{1,3})" $urlStr -> urlProto ni1 ni2 ni3 ni4]} {
     # Check if the IP is on local network
     if {$ni1 == 127 || $ni1 == 10 || ($ni1 == 192 && $ni2 == 168)} {
       urllog_verb_msg 1 $urlNick $urlChan "err_url_local_net" [list $urlStr]
@@ -323,7 +323,7 @@
 
   ### Get URL protocol component
   set urlProto ""
-  if  {[regexp "(\[a-z\]+)://" $urlStr urlMatch urlProto]} {
+  if  {[regexp "(\[a-z\]+)://" $urlStr -> urlProto]} {
     ### Is it a http or ftp url?
     if {$urlProto != "http" && $urlProto != "https" && $urlProto != "ftp"} {
       urllog_verb_msg 1 $urlNick $urlChan "err_url_proto_class" [list $urlStr $urlProto]
@@ -457,13 +457,13 @@
       set uencoding ""
 
       # Get information about specified character encodings
-      if {[info exists umeta(content-type)] && [regexp -nocase {charset\s*=\s*([a-z0-9._-]+)} $umeta(content-type) umatches uenc_http]} {
+      if {[info exists umeta(content-type)] && [regexp -nocase {charset\s*=\s*([a-z0-9._-]+)} $umeta(content-type) -> uenc_http]} {
         # Found character set encoding information in HTTP headers
       }
 
-      if {[regexp -nocase -- "<meta.\*\?content=\"text/html.\*\?charset=(\[^\"\]*)\".\*\?/\?>" $udata umatches uenc_doc]} {
+      if {[regexp -nocase -- "<meta.\*\?content=\"text/html.\*\?charset=(\[^\"\]*)\".\*\?/\?>" $udata -> uenc_doc]} {
         # Found old style HTML meta tag with character set information
-      } elseif {[regexp -nocase -- "<meta.\*\?charset=\"(\[^\"\]*)\".\*\?/\?>" $udata umatches uenc_doc]} {
+      } elseif {[regexp -nocase -- "<meta.\*\?charset=\"(\[^\"\]*)\".\*\?/\?>" $udata -> uenc_doc]} {
         # Found HTML5 style meta tag with character set information
       }
 
@@ -486,15 +486,15 @@
       # Get the document title, if any
       set urlTitle ""
 
-      if {[regexp -nocase -- "<meta name=\"twitter:title\" content=\"(.\*\?)\"\\s\*\/\?>" $udata umatches urlTitle]} {
+      if {[regexp -nocase -- "<meta name=\"twitter:title\" content=\"(.\*\?)\"\\s\*\/\?>" $udata -> urlTitle]} {
         # ...
-      } elseif {[regexp -nocase -- "<title.\*\?>(.\*\?)</title>" $udata umatches urlTitle]} {
+      } elseif {[regexp -nocase -- "<title.\*\?>(.\*\?)</title>" $udata -> urlTitle]} {
         # ...
       }
 
       # If facebook, get meta info
       if {[regexp -nocase -- "(http|https):\/\/www.facebook.com" $urlStr]} {
-        if {[regexp -nocase -- "<meta name=\"description\" content=\"(.\*\?)\"" $udata umatches urlTmp]} {
+        if {[regexp -nocase -- "<meta name=\"description\" content=\"(.\*\?)\"" $udata -> urlTmp]} {
           if {$urlTitle != ""} { append urlTitle " :: " }
           append urlTitle $urlTmp
         }