summaryrefslogtreecommitdiffstats
path: root/util/find-doc-nits
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-05-25 10:29:24 +0200
committerRichard Levitte <levitte@openssl.org>2021-05-26 15:15:18 +0200
commit0e7e3b9b9d2d0a49097b4e224098036d3e6b8087 (patch)
treec7fe80296221c2190f3de92a858cc992fa49aadb /util/find-doc-nits
parentTEST: Add test specific fipsmodule.cnf, and use it (diff)
downloadopenssl-0e7e3b9b9d2d0a49097b4e224098036d3e6b8087.tar.xz
openssl-0e7e3b9b9d2d0a49097b4e224098036d3e6b8087.zip
util/fix-doc-nits: Fix link detection in collectnames() to be kinder
The way the links were parsed out of the contents caused a regexp recursion. The easiest way to deal with it is to find all markup using $markup_re, and then parsing out the L markups and add them to the links array. Fixes #15449 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15450)
Diffstat (limited to '')
-rwxr-xr-xutil/find-doc-nits31
1 files changed, 21 insertions, 10 deletions
diff --git a/util/find-doc-nits b/util/find-doc-nits
index c62307a9ce..7498ac6865 100755
--- a/util/find-doc-nits
+++ b/util/find-doc-nits
@@ -1000,16 +1000,27 @@ sub collectnames {
}
}
- my @links =
- $podinfo{contents} =~ /L<
- # if the link is of the form L<something|name(s)>,
- # then remove 'something'. Note that 'something'
- # may contain POD codes as well...
- (?:(?:[^\|]|<[^>]*>)*\|)?
- # we're only interested in references that have
- # a one digit section number
- ([^\/>\(]+\(\d\))
- /gx;
+ my @links = ();
+ # Don't use this regexp directly on $podinfo{contents}, as it causes
+ # a regexp recursion, which fails on really big PODs. Instead, use
+ # $markup_re to pick up general markup, and use this regexp to check
+ # that the markup that was found is indeed a link.
+ my $linkre = qr/L<
+ # if the link is of the form L<something|name(s)>,
+ # then remove 'something'. Note that 'something'
+ # may contain POD codes as well...
+ (?:(?:[^\|]|<[^>]*>)*\|)?
+ # we're only interested in references that have
+ # a one digit section number
+ ([^\/>\(]+\(\d\))
+ /x;
+ while ( $podinfo{contents} =~ /$markup_re/msg ) {
+ my $x = $1;
+
+ if ($x =~ $linkre) {
+ push @links, $1;
+ }
+ }
$link_map{$filename} = [ @links ];
}