Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make search.tcl more robust in the face of malformed MATCH queries. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | branch-3.8.10 |
Files: | files | file ages | folders |
SHA1: |
f2337fb9a2cf14f6794836b5e9d10415 |
User & Date: | drh 2015-06-26 19:17:30.229 |
Context
2015-07-01
| ||
17:34 | Fix a typo in the zero-malloc memory allocator documentation. (Leaf check-in: a3a3160989 user: drh tags: branch-3.8.10) | |
2015-06-26
| ||
19:17 | Make search.tcl more robust in the face of malformed MATCH queries. (check-in: f2337fb9a2 user: drh tags: branch-3.8.10) | |
19:15 | Make search.tcl more robust in the face of malformed MATCH queries. (check-in: 04c0c2b5f2 user: dan tags: trunk) | |
2015-05-30
| ||
20:54 | Fix a typo in the SQLITE_BUSY_SNAPSHOT documentation. (check-in: d025188e91 user: drh tags: branch-3.8.10) | |
Changes
Changes to search/search.tcl.
︙ | ︙ | |||
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | # Count the '"' characters in $::A(q). If there is an odd number of # occurences, add a " to the end of the query so that fts3 can parse # it without error. if {[regexp -all \x22 $::A(q)] % 2} { append ::A(q) \x22 } set ::TITLE "Results for: \"[htmlize $::A(q)]\"" #db func rank rank #db func erank erank # If the user has clicked the "Lucky" button and the query returns one or # more results, redirect the browser to the highest ranked result. If the # query returns zero results, fall through and display the "No results" # page as if the user had clicked "Search". # if {[info exists ::A(s)] && $::A(s) == "Lucky"} { set url [db one { SELECT url FROM page, pagedata WHERE page MATCH $::A(q) AND page.docid = pagedata.docid ORDER BY rank(matchinfo(page), nk, nt, nc) DESC }] if {$url != ""} { cgi_redirect $url } } | > > > > > > > > > > < < < < | < > > | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | # Count the '"' characters in $::A(q). If there is an odd number of # occurences, add a " to the end of the query so that fts3 can parse # it without error. if {[regexp -all \x22 $::A(q)] % 2} { append ::A(q) \x22 } set ::TITLE "Results for: \"[htmlize $::A(q)]\"" # Set nRes to the total number of documents that the user's query matches. # set rc [catch { set nRes [db one { SELECT count(*) FROM page WHERE page MATCH $::A(q) }] }] if {$rc} { set ::A(q) "\"$::A(q)\"" set nRes [db one { SELECT count(*) FROM page WHERE page MATCH $::A(q) }] } #db func rank rank #db func erank erank # If the user has clicked the "Lucky" button and the query returns one or # more results, redirect the browser to the highest ranked result. If the # query returns zero results, fall through and display the "No results" # page as if the user had clicked "Search". # if {[info exists ::A(s)] && $::A(s) == "Lucky"} { set url [db one { SELECT url FROM page, pagedata WHERE page MATCH $::A(q) AND page.docid = pagedata.docid ORDER BY rank(matchinfo(page), nk, nt, nc) DESC }] if {$url != ""} { cgi_redirect $url } } # If nRes is 0, then the user's query returned zero results. Return a short # message to that effect. # if {$nRes == 0} { return [subst { No results for: <b>[htmlize $::A(q)]</b> }] } set score 0 catch {set score $::A(score)} # Set iStart to the index of the first result to display. Results are # indexed starting at zero from most to least relevant. # set iStart [expr {([info exists ::A(i)] ? $::A(i) : 0)*10}] # HTML markup used to highlight keywords within FTS3 generated snippets. |
︙ | ︙ |