8000 bpo-41944: No longer call eval() on content received via HTTP in the UnicodeNames tests by The-Compiler · Pull Request #22575 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-41944: No longer call eval() on content received via HTTP in the UnicodeNames tests #22575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-41944: No longer call eval() on content received via HTTP in the …
…UnicodeNames tests

Similarly to GH-22566, those tests called eval() on content received via
HTTP in test_named_sequences_full. This likely isn't exploitable because
unicodedata.lookup(seqname) is called before self.checkletter(seqname,
None) - thus any string which isn't a valid unicode character name
wouldn't ever reach the checkletter method.

Still, it's probably better to be safe than sorry.
  • Loading branch information
The-Compiler committed Oct 6, 2020
commit fc888ef6ee2c48bc6541fbb53180bede976e0ffb
3 changes: 2 additions & 1 deletion Lib/test/test_ucn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

"""#"

import ast
import unittest
import unicodedata

Expand All @@ -24,7 +25,7 @@ def checkletter(self, name, code):
# Helper that put all \N escapes inside eval'd raw strings,
# to make sure this script runs even if the compiler
# chokes on \N escapes
res = eval(r'"\N{%s}"' % name)
res = ast.literal_eval(r'"\N{%s}"' % name)
self.assertEqual(res, code)
return res

Expand Down
0