Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
78de0119
Commit
78de0119
authored
Dec 29, 2018
by
Xtreak
Committed by
Serhiy Storchaka
Dec 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35603: Escape table header of make_table output that can cause potential XSS. (GH-11341)
parent
1f511e1a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
Lib/difflib.py
Lib/difflib.py
+4
-0
Lib/test/test_difflib.py
Lib/test/test_difflib.py
+9
-0
Misc/NEWS.d/next/Library/2018-12-28-14-53-22.bpo-35603.rVCZAE.rst
...S.d/next/Library/2018-12-28-14-53-22.bpo-35603.rVCZAE.rst
+2
-0
No files found.
Lib/difflib.py
View file @
78de0119
...
@@ -2036,6 +2036,10 @@ class HtmlDiff(object):
...
@@ -2036,6 +2036,10 @@ class HtmlDiff(object):
s
.
append
(
fmt
%
(
next_id
[
i
],
next_href
[
i
],
fromlist
[
i
],
s
.
append
(
fmt
%
(
next_id
[
i
],
next_href
[
i
],
fromlist
[
i
],
next_href
[
i
],
tolist
[
i
]))
next_href
[
i
],
tolist
[
i
]))
if
fromdesc
or
todesc
:
if
fromdesc
or
todesc
:
fromdesc
=
fromdesc
.
replace
(
"&"
,
"&"
).
replace
(
">"
,
">"
)
\
.
replace
(
"<"
,
"<"
)
todesc
=
todesc
.
replace
(
"&"
,
"&"
).
replace
(
">"
,
">"
)
\
.
replace
(
"<"
,
"<"
)
header_row
=
'<thead><tr>%s%s%s%s</tr></thead>'
%
(
header_row
=
'<thead><tr>%s%s%s%s</tr></thead>'
%
(
'<th class="diff_next"><br /></th>'
,
'<th class="diff_next"><br /></th>'
,
'<th colspan="2" class="diff_header">%s</th>'
%
fromdesc
,
'<th colspan="2" class="diff_header">%s</th>'
%
fromdesc
,
...
...
Lib/test/test_difflib.py
View file @
78de0119
...
@@ -238,6 +238,15 @@ class TestSFpatches(unittest.TestCase):
...
@@ -238,6 +238,15 @@ class TestSFpatches(unittest.TestCase):
with
open
(
findfile
(
'test_difflib_expect.html'
))
as
fp
:
with
open
(
findfile
(
'test_difflib_expect.html'
))
as
fp
:
self
.
assertEqual
(
actual
,
fp
.
read
())
self
.
assertEqual
(
actual
,
fp
.
read
())
def
test_make_table_escape_table_header
(
self
):
html_diff
=
difflib
.
HtmlDiff
()
output
=
html_diff
.
make_table
(
patch914575_from1
.
splitlines
(),
patch914575_to1
.
splitlines
(),
fromdesc
=
'<from>'
,
todesc
=
'<to>'
)
self
.
assertIn
(
'<from>'
,
output
)
self
.
assertIn
(
'<to>'
,
output
)
def
test_recursion_limit
(
self
):
def
test_recursion_limit
(
self
):
# Check if the problem described in patch #1413711 exists.
# Check if the problem described in patch #1413711 exists.
limit
=
sys
.
getrecursionlimit
()
limit
=
sys
.
getrecursionlimit
()
...
...
Misc/NEWS.d/next/Library/2018-12-28-14-53-22.bpo-35603.rVCZAE.rst
0 → 100644
View file @
78de0119
Escape table header output of :meth:`difflib.HtmlDiff.make_table`.
Patch by Karthikeyan Singaravelan.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment