summaryrefslogtreecommitdiffstats
path: root/addon
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2014-12-23 20:07:11 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2014-12-23 20:07:11 (GMT)
commit5d266c5d7f7b05dcfa8d3485bc43e268dd8fe90a (patch)
tree1b937d7572eed5cd3ddedec107989a18636a82bd /addon
parent07d5f3f48a497993c525eab9a5ecc0429c317c98 (diff)
downloadDoxygen-5d266c5d7f7b05dcfa8d3485bc43e268dd8fe90a.zip
Doxygen-5d266c5d7f7b05dcfa8d3485bc43e268dd8fe90a.tar.gz
Doxygen-5d266c5d7f7b05dcfa8d3485bc43e268dd8fe90a.tar.bz2
Prevent overly long terms from stopping the search indexer
Diffstat (limited to 'addon')
-rw-r--r--addon/doxysearch/doxyindexer.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/addon/doxysearch/doxyindexer.cpp b/addon/doxysearch/doxyindexer.cpp
index b44a940..e1006be 100644
--- a/addon/doxysearch/doxyindexer.cpp
+++ b/addon/doxysearch/doxyindexer.cpp
@@ -30,12 +30,19 @@
// Xapian include
#include <xapian.h>
+#define MAX_TERM_LENGTH 245
+
#if defined(_WIN32) && !defined(__CYGWIN__)
static char pathSep = '\\';
#else
static char pathSep = '/';
#endif
+static void safeAddTerm(const std::string &term,Xapian::Document &doc,int wfd)
+{
+ if (term.length()<=MAX_TERM_LENGTH) doc.add_term(term,wfd);
+}
+
/** trims \a whitespace characters from the start and end of string \a str. */
static std::string trim(const std::string& str,
const std::string& whitespace = " \t")
@@ -86,10 +93,10 @@ static void addWords(const std::string &s,Xapian::Document &doc,int wfd)
std::string word = *it;
std::string lword = word;
std::transform(lword.begin(), lword.end(), lword.begin(), ::tolower);
- doc.add_term(word,wfd);
+ safeAddTerm(word,doc,wfd);
if (lword!=word)
{
- doc.add_term(lword,wfd);
+ safeAddTerm(lword,doc,wfd);
}
}
}
@@ -102,7 +109,7 @@ static void addIdentifiers(const std::string &s,Xapian::Document &doc,int wfd)
QCString qs = s.c_str();
while ((i=re.match(qs,p,&l))!=-1)
{
- doc.add_term(qs.mid(p,i-p).data(),wfd);
+ safeAddTerm(qs.mid(p,i-p).data(),doc,wfd);
p=i+l;
}
}
@@ -201,18 +208,18 @@ class XMLContentHandler : public QXmlDefaultHandler
m_doc.get_value(TypeField)=="file" ||
m_doc.get_value(TypeField)=="namespace") // containers get highest prio
{
- m_doc.add_term(term,1000);
+ safeAddTerm(term,m_doc,1000);
if (!partTerm.empty())
{
- m_doc.add_term(partTerm,500);
+ safeAddTerm(partTerm,m_doc,500);
}
}
else // members and others get lower prio
{
- m_doc.add_term(m_doc.get_value(NameField),100);
+ safeAddTerm(m_doc.get_value(NameField),m_doc,100);
if (!partTerm.empty())
{
- m_doc.add_term(partTerm,50);
+ safeAddTerm(partTerm,m_doc,50);
}
}
m_db.add_document(m_doc);