changeset 579:fec0911e9ef9

urllog: Remove TLD checks, as they are rather useless nowadays.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 04 Jan 2021 12:17:43 +0200
parents 14dfb925a64a
children ca535e7eb0ed
files urllog.tcl
diffstat 1 files changed, 2 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/urllog.tcl	Mon Jan 04 12:00:44 2021 +0200
+++ b/urllog.tcl	Mon Jan 04 12:17:43 2021 +0200
@@ -41,7 +41,6 @@
 set urllog_message "$urllog_name v$urllog_version (C) 2000-2021 ccr/TNSP"
 
 
-set urllog_tld_list [split $urllog_tld_list ","]
 set urllog_httprep [split "\@|%40|{|%7B|}|%7D|\[|%5B|\]|%5D" "|"]
 set urllog_shorturl_str "ABCDEFGHIJKLNMOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
 
@@ -235,14 +234,12 @@
 
 #-------------------------------------------------------------------------
 proc urllog_validate_url { urlNick urlChan urlMStr urlMProto urlMHostName } {
-  global urllog_tld_list urlmsg_nosuchhost urllog_httprep urlmsg_unknown_tld
-  global urllog_shorturl_prefix urllog_shorturl urllog_check_tld
+  global urlmsg_nosuchhost urllog_httprep
+  global urllog_shorturl_prefix urllog_shorturl
   upvar 1 $urlMStr urlStr
   upvar 1 $urlMProto urlProto
   upvar 1 $urlMHostName urlHostName
 
-  set u_checktld 1
-
   ### Hack for removing parenthesis around an URL
   if {[regexp {^\((.+)\)$} $urlStr urlMatch urlClean]} {
     set urlStr $urlClean
@@ -269,8 +266,6 @@
       urllog_log "URL pointing to invalid network, ignored ($urlStr)."
       return 0
     }
-    # Skip TLD check for URLs with IP address
-    set u_checktld 0
   }
 
   ### Check now if we have an ShortURL here ...
@@ -308,30 +303,6 @@
     return 0
   }
 
-  ### Check the Top Level Domain (TLD) validity
-  if {$urllog_check_tld != 0 && $u_checktld != 0} {
-    set u_sane [lindex [split $urlHostName "."] end]
-    set u_tld [lindex [split $u_sane ":"] 0]
-    set u_found 0
-
-    if {[string length $u_tld] == 2} {
-      # Assume all 2-letter domains to be valid :)
-      set u_found 1
-    } else {
-      # Check our list of known TLDs
-      foreach itld $urllog_tld_list {
-        if {[string match $itld $u_tld]} {
-          set u_found 1
-        }
-      }
-    }
-
-    if {$u_found == 0} {
-      urllog_log "Broken URL from $urlNick: ($urlStr) unknown TLD: ${u_tld}."
-      urllog_verb_msg $urlNick $urlChan $urlmsg_unknown_tld
-      return 0
-    }
-  }
 
   set urlStr [string map $urllog_httprep $urlStr]
   return 1
@@ -611,10 +582,6 @@
   putlog " - Additional URL validity checks enabled."
 }
 
-if {$urllog_check_tld != 0} {
-  putlog " - Check TLD enabled."
-}
-
 if {$urllog_verbose != 0} {
   putlog " - Verbose mode enabled."
 }