make sure that content is defined before testing for search patterns

This appears to have been causing a bug with comments/text that were deleted.
Kaylea fixed and I adapated the code.
This commit is contained in:
Benjamin Mako Hill 2023-04-28 14:30:42 -07:00
parent 556285b198
commit 7e6cd5b386

4
wikiq
View File

@ -146,7 +146,7 @@ class RegexPair(object):
if self.has_groups: if self.has_groups:
# if there are matches of some sort in this revision content, fill the lists for each cap_group # if there are matches of some sort in this revision content, fill the lists for each cap_group
if self.pattern.search(content) is not None: if content is not None and self.pattern.search(content) is not None:
m = self.pattern.finditer(content) m = self.pattern.finditer(content)
matchobjects = list(m) matchobjects = list(m)
@ -174,7 +174,7 @@ class RegexPair(object):
# there are no capture groups, we just search for all the matches of the regex # there are no capture groups, we just search for all the matches of the regex
else: else:
#given that there are matches to be made #given that there are matches to be made
if self.pattern.search(content) is not None: if content is not None and self.pattern.search(content) is not None:
m = self.pattern.findall(content) m = self.pattern.findall(content)
temp_dict[self.label] = ', '.join(m) temp_dict[self.label] = ', '.join(m)
else: else: