Simon Steiner created PDFBOX-6363:
-------------------------------------

             Summary: PDFHighlighter treats search words as regular 
expressions, so user terms can hang a thread or throw
                 Key: PDFBOX-6363
                 URL: https://issues.apache.org/jira/browse/PDFBOX-6363
             Project: PDFBox
          Issue Type: Bug
            Reporter: Simon Steiner


PDFHighlighter.generateXMLHighlight takes one or more search words, documented 
as "the word to search for". At the end of each page, endPage passes each word 
straight to Pattern.compile(searchedWord, Pattern.CASE_INSENSITIVE) and runs 
matcher.find() over the whole page text. The words are never escaped with 
Pattern.quote or Pattern.LITERAL, so regex metacharacters are interpreted. A 
term with nested quantifiers can backtrack catastrophically against the page 
text. A term with an unbalanced bracket, or a word like C++, throws an 
unchecked PatternSyntaxException instead of the declared IOException. A . 
matches any character, so highlight positions come out wrong.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to