Escape single and double quotes as well, plus add test
This commit is contained in:
parent
a233a0ca72
commit
1c7f83acf6
2 changed files with 17 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from kojiweb.util import formatMode, formatLink
|
||||
from kojiweb.util import formatMode, formatLink, escapeHTML
|
||||
|
||||
class TestFormatMode(unittest.TestCase):
|
||||
def test_format_mode(self):
|
||||
|
|
@ -34,3 +34,14 @@ class TestFormatMode(unittest.TestCase):
|
|||
|
||||
for input, output in formats:
|
||||
self.assertEqual(formatLink(input), output)
|
||||
|
||||
def test_escape_html(self):
|
||||
tests = (
|
||||
('test me', 'test me'),
|
||||
('test <danger>', 'test <danger>'),
|
||||
('test <danger="true">', 'test <danger="true">'),
|
||||
("test <danger='true'>", 'test <danger='true'>'),
|
||||
)
|
||||
|
||||
for input, output in tests:
|
||||
self.assertEqual(escapeHTML(input), output)
|
||||
|
|
|
|||
|
|
@ -593,6 +593,8 @@ def escapeHTML(value):
|
|||
< : <
|
||||
> : >
|
||||
& : &
|
||||
" : "
|
||||
' : '
|
||||
"""
|
||||
if not value:
|
||||
return value
|
||||
|
|
@ -600,7 +602,9 @@ def escapeHTML(value):
|
|||
value = koji.fixEncoding(value)
|
||||
return value.replace('&', '&').\
|
||||
replace('<', '<').\
|
||||
replace('>', '>')
|
||||
replace('>', '>').\
|
||||
replace('"', '"').\
|
||||
replace("'", ''')
|
||||
|
||||
|
||||
def authToken(template, first=False, form=False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue