From f00e75278c5999f40b214d8934357fbf0e705417 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 20 Sep 2020 17:34:49 +0900 Subject: [PATCH] Fix #8172: napoleon: Potential of regex denial of service in google style docs --- CHANGES | 1 + sphinx/ext/napoleon/docstring.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 89980530f..a0dcc3998 100644 --- a/CHANGES +++ b/CHANGES @@ -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'(?