commentparser: Allow signature of user '0' to be detected

Bug: T379918
Change-Id: I11a447c11fe64dae88a5035b007fe762a335e6c5
This commit is contained in:
Ammarpad 2024-11-14 15:03:50 +01:00
parent ad99faef19
commit 84d0dfc51c

View file

@ -605,7 +605,7 @@ class CommentParser {
$username = $userpage->getText(); $username = $userpage->getText();
} }
} }
if ( !$username ) { if ( $username === null ) {
return null; return null;
} }
if ( IPUtils::isIPv6( $username ) ) { if ( IPUtils::isIPv6( $username ) ) {
@ -924,7 +924,7 @@ class CommentParser {
$foundSignature = $this->findSignature( $node, $curCommentEnd ); $foundSignature = $this->findSignature( $node, $curCommentEnd );
$author = $foundSignature['username']; $author = $foundSignature['username'];
if ( !$author ) { if ( $author === null ) {
// Ignore timestamps for which we couldn't find a signature. It's probably not a real // Ignore timestamps for which we couldn't find a signature. It's probably not a real
// comment, but just a false match due to a copypasted timestamp. // comment, but just a false match due to a copypasted timestamp.
continue; continue;
@ -969,7 +969,7 @@ class CommentParser {
$treeWalker->currentNode = $n; $treeWalker->currentNode = $n;
// …and add it as another signature to this comment (regardless of the author and timestamp) // …and add it as another signature to this comment (regardless of the author and timestamp)
$foundSignature2 = $this->findSignature( $n, $node ); $foundSignature2 = $this->findSignature( $n, $node );
if ( $foundSignature2['username'] ) { if ( $foundSignature2['username'] !== null ) {
$sigRanges[] = $this->adjustSigRange( $foundSignature2['nodes'], $match2, $n ); $sigRanges[] = $this->adjustSigRange( $foundSignature2['nodes'], $match2, $n );
$timestampRanges[] = $match2['range']; $timestampRanges[] = $match2['range'];
} }