Ticket #87: omega-terms-with-dots-fix.patch
File omega-terms-with-dots-fix.patch, 2.1 KB (added by , 18 years ago) |
---|
-
query.cc
218 218 } 219 219 220 220 // Check new query against the previous one 221 const char *pend;222 const char *term;223 unsigned int n_old_terms = 0;224 225 221 if (oldp.empty()) return query_string.empty() ? SAME_QUERY : NEW_QUERY; 226 222 227 223 // We used to use "word1#word2#" (with trailing #) but some broken old 228 224 // browsers (versions of MSIE) don't quote # in form GET submissions 229 225 // and everything after the # gets interpreted as an anchor. 230 // So now we use "word1.word2." instead. 231 term = oldp.c_str(); 232 pend = term; 233 while ((pend = strchr(pend, '.')) != NULL) { 234 pend++; 235 n_old_terms++; 226 // 227 // So we switched to using "word1.word2." but that doesn't work if 228 // the terms contain "." themselves (e.g. Tapplication/vnd.ms-excel) 229 // so now we use "word1\tword2" instead (with no trailing separator). 230 // 231 // However for compatibility with templates which haven't been updated and 232 // bookmarked queries from Omega 0.9.6 and earlier we still support ".". 233 char separator = '\t'; 234 unsigned int n_old_terms = count(oldp.begin(), oldp.end(), '\t') + 1; 235 if (n_old_terms == 1 && oldp[oldp.size() - 1] == '.') { 236 separator = '.'; 237 n_old_terms = count(oldp.begin(), oldp.end(), '.'); 236 238 } 239 237 240 // short-cut: if the new query has fewer terms, it must be a new one 238 241 if (n_new_terms < n_old_terms) return NEW_QUERY; 239 242 240 while ((pend = strchr(term, '.')) != NULL) { 243 const char *term = oldp.c_str(); 244 const char *pend; 245 while ((pend = strchr(term, separator)) != NULL) { 241 246 if (termset.find(string(term, pend - term)) == termset.end()) 242 247 return NEW_QUERY; 243 248 term = pend + 1; 244 249 } 250 if (*term) { 251 if (termset.find(string(term)) == termset.end()) 252 return NEW_QUERY; 253 } 254 245 255 // Use termset.size() rather than n_new_terms so we correctly handle 246 256 // the case when the query has repeated terms. 247 257 // This works wrongly in the case when the user extends the query