Merge pull request #8224 from tk0miya/8172_napoleon_redos

Fix #8172: napoleon: Potential of regex denial of service in google style docs
This commit is contained in:
Takeshi KOMIYA 2020-09-28 01:27:57 +09:00 committed by GitHub
commit a81c45367a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -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)

View File

@ -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)