diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-07-04 18:11:51 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-07-04 18:11:51 (GMT) |
commit | 2cc8a5e4903b688f53e12141e3813d044dc05600 (patch) | |
tree | a995ee5e198c4a3807fcfc7ba8c9f72f9f90929d /Modules | |
parent | 7cb6f2fe109f0231c4b11de03d2d5d96ca656f4d (diff) | |
download | cpython-2cc8a5e4903b688f53e12141e3813d044dc05600.zip cpython-2cc8a5e4903b688f53e12141e3813d044dc05600.tar.gz cpython-2cc8a5e4903b688f53e12141e3813d044dc05600.tar.bz2 |
Issue #9130: Fix validation of relative imports in parser module.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/parsermodule.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index e60f23d..bead663 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -1767,8 +1767,8 @@ count_from_dots(node *tree) return i-1; } -/* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' | - * import_as_names +/* import_from: ('from' ('.'* dotted_name | '.'+) + * 'import' ('*' | '(' import_as_names ')' | import_as_names)) */ static int validate_import_from(node *tree) @@ -1778,7 +1778,8 @@ validate_import_from(node *tree) int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name); int offset = ndots + havename; int res = validate_ntype(tree, import_from) - && (nch >= 4 + ndots) + && (offset >= 1) + && (nch >= 3 + offset) && validate_name(CHILD(tree, 0), "from") && (!havename || validate_dotted_name(CHILD(tree, ndots + 1))) && validate_name(CHILD(tree, offset + 1), "import"); |