diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-09-20 17:34:49 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-09-20 17:34:49 +0900 |
commit | f00e75278c5999f40b214d8934357fbf0e705417 (patch) | |
tree | 7abc47b450076ec5c413c75e1158b536e922309a | |
parent | 0b44e68d4fed408453859dd9a83dc3ee68d90c7f (diff) | |
download | sphinx-git-f00e75278c5999f40b214d8934357fbf0e705417.tar.gz |
Fix #8172: napoleon: Potential of regex denial of service in google style docs
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | sphinx/ext/napoleon/docstring.py | 4 |
2 files changed, 3 insertions, 2 deletions
@@ -20,6 +20,7 @@ Bugs fixed * #8143: autodoc: AttributeError is raised when False value is passed to autodoc_default_options * #8192: napoleon: description is disappeared when it contains inline literals +* #8172: napoleon: Potential of regex denial of service in google style docs * #8093: The highlight warning has wrong location in some builders (LaTeX, singlehtml and so on) diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index 97eaa0fd6..d36fdd17a 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -31,7 +31,7 @@ logger = logging.getLogger(__name__) _directive_regex = re.compile(r'\.\. \S+::') _google_section_regex = re.compile(r'^(\s|\w)+:\s*$') -_google_typed_arg_regex = re.compile(r'\s*(.+?)\s*\(\s*(.*[^\s]+)\s*\)') +_google_typed_arg_regex = re.compile(r'(.+?)\(\s*(.*[^\s]+)\s*\)') _numpy_section_regex = re.compile(r'^[=\-`:\'"~^_*+#<>]{2,}\s*$') _single_colon_regex = re.compile(r'(?<!:):(?!:)') _xref_or_code_regex = re.compile( @@ -254,7 +254,7 @@ class GoogleDocstring: if parse_type: match = _google_typed_arg_regex.match(before) if match: - _name = match.group(1) + _name = match.group(1).strip() _type = match.group(2) _name = self._escape_args_and_kwargs(_name) |