When link parsing is performed within Linkvalidator,
several SoftReferenceParsers are applied on the
existing content. More than one may match, e.g.
external URL and typolink.
This resulted in problems where 2 links were extracted
from the content even though only one existed. This
happened specifically, if the anchor text (link text)
contained an URL.
An earlier version of this patch tried to fix this by
replacing the field content with an empty string once
any SoftReferenceParser had matched something, via
SoftReferenceParserResult::createWithoutMatches(). Since
that method is static and ignores the parser result it is
called on, this always yielded an empty string, which in
turn made all other configured SoftReferenceParsers for
that field silently stop finding any further, unrelated
links (e.g. a distinct URL used elsewhere in the same
field), as already pointed out during review.
This patch instead tracks the actual link targets already
found for a given table/field/record combination across
all its configured SoftReferenceParsers and skips adding
a result for a link target that was already found by a
previous parser. This still keeps the original field
content intact for every parser, so unrelated links are
found as before, while a link that is matched more than
once (e.g. because its URL is also used as its own link
text) is only reported once.
Additionally, several tests are added for
LinkAnalyzer::analyzeRecord(), as
tests did not yet exist for this method.