Mercurial > hg > egg-tcls
diff quotedb.tcl @ 295:141bb4a2b76f
utillib: utl_escape (which will be deprecated soon).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 26 Jan 2015 14:07:16 +0200 |
parents | 42ba48d54324 |
children | db46078c7028 |
line wrap: on
line diff
--- a/quotedb.tcl Mon Jan 26 14:04:17 2015 +0200 +++ b/quotedb.tcl Mon Jan 26 14:07:16 2015 +0200 @@ -76,10 +76,6 @@ } -proc qdb_escape {str} { - return [string map {' ''} $str] -} - proc qdb_sql_exec { upublic unick uchan usql } { global qdb_handle qdb_msg_sql_error if {[catch {qdb_handle eval $usql} uerrmsg]} { @@ -112,7 +108,7 @@ return 0 } - set usql "INSERT INTO $utable (utime,utext,user,host,chan) VALUES ([unixtime], '[qdb_escape $utext]', '[qdb_escape $uhand]', '[qdb_escape $uhost]', '[qdb_escape $uchan]')" + set usql "INSERT INTO $utable (utime,utext,user,host,chan) VALUES ([unixtime], '[utl_escape $utext]', '[utl_escape $uhand]', '[utl_escape $uhost]', '[utl_escape $uchan]')" if {![qdb_sql_exec $upublic $unick $uchan $usql]} { return 0 } @@ -149,7 +145,7 @@ set qoverride [matchattr $uhand n] set usql "SELECT utime AS utime FROM $utable WHERE id=$unum" if {$qoverride == 0} { - append usql " AND user='[qdb_escape $uhand]'" + append usql " AND user='[utl_escape $uhand]'" set qextra "" } else { set qextra " (owner/time override)" @@ -199,7 +195,7 @@ set qoverride [matchattr $uhand n] set usql "SELECT utime AS utime FROM $utable WHERE id=$unum" if {$qoverride == 0} { - append usql " AND user='[qdb_escape $uhand]'" + append usql " AND user='[utl_escape $uhand]'" set qextra "" } else { set qextra $qdb_msg_update_override @@ -208,7 +204,7 @@ qdb_handle eval $usql { set udiff [expr [unixtime] - $utime] if {$udiff < $maxdiff || $qoverride} { - set usql "UPDATE $utable SET utext='[qdb_escape $uquote]', utime=[unixtime] WHERE id=$unum" + set usql "UPDATE $utable SET utext='[utl_escape $uquote]', utime=[unixtime] WHERE id=$unum" if {![qdb_sql_exec $upublic $unick $uchan $usql]} { return 0 } else { @@ -275,7 +271,7 @@ } # Check if user has previously voted this item - set usql "SELECT id AS qid FROM ${utable}_votes WHERE user='[qdb_escape $uhand]' AND urlid=$uid" + set usql "SELECT id AS qid FROM ${utable}_votes WHERE user='[utl_escape $uhand]' AND urlid=$uid" qdb_handle eval $usql { # Yes, update the previous vote set usql "UPDATE ${utable}_votes SET vote=$uvote WHERE id=$qid" @@ -289,7 +285,7 @@ } # No previous votes, insert new - set usql "INSERT INTO ${utable}_votes (user,urlid,vote) VALUES ('[qdb_escape $uhand]',$uid,$uvote)" + set usql "INSERT INTO ${utable}_votes (user,urlid,vote) VALUES ('[utl_escape $uhand]',$uid,$uvote)" if {[qdb_sql_exec $upublic $unick $uchan $usql]} { qdb_log "$uhand voted $uvote on #$uid / $utable" qdb_msg $upublic $unick $uchan $qdb_msg_you_voted [list $uid $uvote] @@ -343,15 +339,15 @@ set fpattern [string range $ftoken 1 end] if {$fprefix == "-"} { - lappend fpatlist "utext NOT LIKE '%[qdb_escape $fpattern]%'" + lappend fpatlist "utext NOT LIKE '%[utl_escape $fpattern]%'" } elseif {$fprefix == "%"} { - lappend fpatlist "user LIKE '[qdb_escape $fpattern]'" + lappend fpatlist "user LIKE '[utl_escape $fpattern]'" } elseif {$fprefix == "@"} { # foo } elseif {$fprefix == "+"} { - lappend fpatlist "utext LIKE '%[qdb_escape $fpattern]%'" + lappend fpatlist "utext LIKE '%[utl_escape $fpattern]%'" } else { - lappend fpatlist "utext LIKE '%[qdb_escape $ftoken]%'" + lappend fpatlist "utext LIKE '%[utl_escape $ftoken]%'" } } if {[llength $fpatlist] > 0} {