diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-04-24 04:30:34 -0700 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-04-25 15:09:07 +0200 |
| commit | 8d76443aba863b75ad3b1392ca7e1d59bad84dc4 (patch) | |
| tree | 1e550f8ebb06a935bd8a15496d049f54c54eded2 /tests/forms_tests | |
| parent | 28d5262fa3315690395f04e3619ed554dbaf725b (diff) | |
Fixed #30399 -- Changed django.utils.html.escape()/urlize() to use html.escape()/unescape().
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 10 | ||||
| -rw-r--r-- | tests/forms_tests/widget_tests/base.py | 5 | ||||
| -rw-r--r-- | tests/forms_tests/widget_tests/test_clearablefileinput.py | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index edce5e801f..18fb4a94de 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -995,7 +995,7 @@ Java</label></li> self.assertHTMLEqual( f.as_table(), """<tr><th><em>Special</em> Field:</th><td> -<ul class="errorlist"><li>Something's wrong with 'Nothing to escape'</li></ul> +<ul class="errorlist"><li>Something's wrong with 'Nothing to escape'</li></ul> <input type="text" name="special_name" value="Nothing to escape" required></td></tr> <tr><th><em>Special</em> Field:</th><td> <ul class="errorlist"><li>'<b>Nothing to escape</b>' is a safe string</li></ul> @@ -1008,10 +1008,10 @@ Java</label></li> self.assertHTMLEqual( f.as_table(), """<tr><th><em>Special</em> Field:</th><td> -<ul class="errorlist"><li>Something's wrong with 'Should escape < & > and -<script>alert('xss')</script>'</li></ul> +<ul class="errorlist"><li>Something's wrong with 'Should escape < & > and +<script>alert('xss')</script>'</li></ul> <input type="text" name="special_name" -value="Should escape < & > and <script>alert('xss')</script>" required></td></tr> +value="Should escape < & > and <script>alert('xss')</script>" required></td></tr> <tr><th><em>Special</em> Field:</th><td> <ul class="errorlist"><li>'<b><i>Do not escape</i></b>' is a safe string</li></ul> <input type="text" name="special_safe_name" value="<i>Do not escape</i>" required></td></tr>""" @@ -2632,7 +2632,7 @@ Password: <input type="password" name="password" required> t.render(Context({'form': UserRegistration(auto_id=False)})), """<form> <p>Username: <input type="text" name="username" maxlength="10" required><br> -Good luck picking a username that doesn't already exist.</p> +Good luck picking a username that doesn't already exist.</p> <p>Password1: <input type="password" name="password1" required></p> <p>Password2: <input type="password" name="password2" required></p> <input type="submit" required> diff --git a/tests/forms_tests/widget_tests/base.py b/tests/forms_tests/widget_tests/base.py index 7222910479..339d78bc71 100644 --- a/tests/forms_tests/widget_tests/base.py +++ b/tests/forms_tests/widget_tests/base.py @@ -22,7 +22,10 @@ class WidgetTest(SimpleTestCase): if self.jinja2_renderer: output = widget.render(name, value, attrs=attrs, renderer=self.jinja2_renderer, **kwargs) # Django escapes quotes with '"' while Jinja2 uses '"'. - assertEqual(output.replace('"', '"'), html) + output = output.replace('"', '"') + # Django escapes single quotes with ''' while Jinja2 uses '''. + output = output.replace(''', ''') + assertEqual(output, html) output = widget.render(name, value, attrs=attrs, renderer=self.django_renderer, **kwargs) assertEqual(output, html) diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py index 2ba376db8a..ff6a1c74e7 100644 --- a/tests/forms_tests/widget_tests/test_clearablefileinput.py +++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py @@ -46,7 +46,7 @@ class ClearableFileInputTest(WidgetTest): self.check_html(ClearableFileInput(), 'my<div>file', StrangeFieldFile(), html=( """ Currently: <a href="something?chapter=1&sect=2&copy=3&lang=en"> - something<div onclick="alert('oops')">.jpg</a> + something<div onclick="alert('oops')">.jpg</a> <input type="checkbox" name="my<div>file-clear" id="my<div>file-clear_id"> <label for="my<div>file-clear_id">Clear</label><br> Change: <input type="file" name="my<div>file"> |
