standardebooks / tools

The Standard Ebooks toolset for producing our ebook files.
Other
1.43k stars 127 forks source link

m-070 (glossary entry search) behaves unexpectedly #731

Closed apasel422 closed 4 months ago

apasel422 commented 4 months ago
  1. It uses regex.search, even though the glossary term being searched for isn't itself a pattern. For the majority of terms, which presumably do not contain regex meta characters, this is fine, but for those that do, the search will unintentionally treat those characters as meta characters instead of literals, leading to incorrect results.
  2. It doesn't use word boundaries in its search, so an entry like foo in the search-key-map will end up being marked as found if the text contains the word food.

For the purposes of (1), we don't even need to use regex.search, which is slow compared to literal string matching, but because we also want to fix (2) I will retain the usage of regex.search but add word boundaries around the escaped term.