diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-09-28 01:27:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 01:27:57 +0900 |
commit | a81c45367a54444b4d534676c06e46538fa5c6b7 (patch) | |
tree | a8dcca3e437a3c9a5f35eaa4fc0eb91b1042cdcb | |
parent | 054dc5d5df73ac21f1af105aa84ba16797ebba1e (diff) | |
parent | f6ae4dd4edd857f8a92c80ee32227aa2d0bcc9d4 (diff) | |
download | sphinx-git-a81c45367a54444b4d534676c06e46538fa5c6b7.tar.gz |
Merge pull request #8224 from tk0miya/8172_napoleon_redos
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
@@ -33,6 +33,7 @@ Bugs fixed * #8190: autodoc: parsing error is raised if some extension replaces docstring by string not ending with blank lines * #8192: napoleon: description is disappeared when it contains inline literals +* #8172: napoleon: Potential of regex denial of service in google style docs * #8169: LaTeX: pxjahyper loaded even when latex_engine is not platex * #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) |