From de5d8063352e075574c7ff78f811efa025c33963 Mon Sep 17 00:00:00 2001 From: sbailey Date: Tue, 24 Nov 2020 12:22:25 -0800 Subject: [PATCH] Cite error tag name defined in references not used before Bug: T51538 Change-Id: Id89b3cc186de42e5e5c05f15d7546db9d64ec864 --- src/Parsoid/References.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Parsoid/References.php b/src/Parsoid/References.php index 357505967..cf1668a64 100644 --- a/src/Parsoid/References.php +++ b/src/Parsoid/References.php @@ -177,8 +177,16 @@ class References extends ExtensionTagHandler { $validFollow = false; - if ( !$hasRefName && $refsData->inReferencesContent() ) { - $errs[] = [ 'key' => 'cite_error_references_no_key' ]; + // FIXME: Reconcile this with `$hasFollow` + if ( $refsData->inReferencesContent() ) { + if ( $hasRefName ) { + $group = $refsData->getRefGroup( $groupName ); + if ( !isset( $group->indexByName[$refName] ) ) { + $errs[] = [ 'key' => 'cite_error_references_missing_key' ]; + } + } else { + $errs[] = [ 'key' => 'cite_error_references_no_key' ]; + } } if ( $hasFollow ) { @@ -213,6 +221,11 @@ class References extends ExtensionTagHandler { // This will be set below with `$ref->contentId = $contentId;` } } else { + // FIXME: This key isn't exactly appropriate since this + // is more general than just being in a + // section and it's the $followName we care about, but the + // extension to the legacy parser doesn't have an + // equivalent key and just outputs something wacky. $errs[] = [ 'key' => 'cite_error_references_missing_key' ]; } }