Skip to content

Commit

Permalink
Re #7081. Automatically fix un-escaped percent signs.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Jun 4, 2013
1 parent 12febcc commit e7686ce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Code/Mantid/docs/qtassistant/eqnparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ def _sanitize(self):
Removes potentially dangerous latex code, replacing it with
a 'LaTeX sanitized' message
"""
# fix bad percent signs
if '%' in self.eqstring:
if self.eqstring[0] == '%':
self.eqstring = "\\" + self.eqstring
index = self.eqstring.find('%', 1)
while index > 0:
if self.eqstring[index-1] == "\\": # it is already escaped
index = self.eqstring.find('%', index+1)
else:
self.eqstring = self.eqstring[:index] + "\\" + self.eqstring[index:]
index = self.eqstring.find('%', index+2) # added a character

# turn everything else bad to junky mbox
lowercase = self.eqstring.lower()
for tag in bad_tags:
if tag in lowercase:
Expand Down

0 comments on commit e7686ce

Please sign in to comment.