comparison urllog.tcl @ 651:ecd8fb2b9ad3

urllog: Use regexp splitx instead of string split.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Feb 2021 11:00:49 +0200
parents 577763cb8864
children 10ea2c1101b3
comparison
equal deleted inserted replaced
650:80db2b265c5f 651:ecd8fb2b9ad3
37 ########################################################################## 37 ##########################################################################
38 # No need to look below this line 38 # No need to look below this line
39 ########################################################################## 39 ##########################################################################
40 package require sqlite3 40 package require sqlite3
41 package require http 41 package require http
42 package require textutil::split
42 43
43 set urllog_name "URLLog" 44 set urllog_name "URLLog"
44 set urllog_version "2.7.0" 45 set urllog_version "2.7.0"
45 set urllog_message "$urllog_name v$urllog_version (C) 2000-2021 ccr/TNSP" 46 set urllog_message "$urllog_name v$urllog_version (C) 2000-2021 ccr/TNSP"
46 47
540 } 541 }
541 542
542 ### Check the channel 543 ### Check the channel
543 if {[utl_match_delim_list $urllog_log_channels $uchan]} { 544 if {[utl_match_delim_list $urllog_log_channels $uchan]} {
544 ### Do the URL checking 545 ### Do the URL checking
545 foreach str [split $utext " "] { 546 foreach str [::textutil::split::splitx $utext {\s+}] {
546 if {[regexp "(\[a-z]+://\[^\[:space:\]\]+|^(www|ftp)\.\[^\[:space:\]\]+)" $str ulink]} { 547 if {[regexp "(\[a-z]+://\[^\[:space:\]\]+|^(www|ftp)\.\[^\[:space:\]\]+)" $str ulink]} {
547 urllog_check_url $str $unick $uhost $uchan 548 urllog_check_url $str $unick $uhost $uchan
548 } 549 }
549 } 550 }
550 } 551 }
564 } else { 565 } else {
565 set ulimit 3 566 set ulimit 3
566 } 567 }
567 568
568 ### Parse the given command 569 ### Parse the given command
569 urllog_log "$unick/$uhand searched URL: $utext" 570 urllog_log "${unick}/${uhand} searched URL: ${utext}"
570 571
571 set ftokens [split $utext " "] 572 set ftokens [::textutil::split::splitx $utext {\s+}]
572 set fpatlist "" 573 set fpatlist ""
573 foreach ftoken $ftokens { 574 foreach ftoken $ftokens {
574 set fprefix [string range $ftoken 0 0] 575 set fprefix [string range $ftoken 0 0]
575 set fpattern [string range $ftoken 1 end] 576 set fpattern [string range $ftoken 1 end]
576 set qpattern "'%[utl_escape $fpattern]%'" 577 set qpattern "'%[utl_escape $fpattern]%'"