mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Added cite error checks for invalid text direction
* Error case of dir= not ltr or rtl is caught and a cite tests validates the new check. Bug: T51538 Change-Id: I8c7e088416f0a000e638771a3fe5e8e0c58bcc23
This commit is contained in:
parent
1ac603ff1c
commit
aadef667d4
|
@ -150,6 +150,7 @@ class References extends ExtensionTagHandler {
|
|||
// to TokenUtils::kvToHash() and ExtensionHandler::normalizeExtOptions()
|
||||
$refName = $refDmw->attrs->name ?? '';
|
||||
$followName = $refDmw->attrs->follow ?? '';
|
||||
$refDir = strtolower( $refDmw->attrs->dir ?? '' );
|
||||
|
||||
// Looks like Cite.php doesn't try to fix ids that already have
|
||||
// a "_" in them. Ex: name="a b" and name="a_b" are considered
|
||||
|
@ -216,6 +217,10 @@ class References extends ExtensionTagHandler {
|
|||
);
|
||||
}
|
||||
|
||||
if ( isset( $refDmw->attrs->dir ) && $refDir !== 'rtl' && $refDir !== 'ltr' ) {
|
||||
$errs[] = [ 'key' => 'cite_error_ref_invalid_dir' ];
|
||||
}
|
||||
|
||||
// Check for missing content, added ?? '' to fix T259676 crasher
|
||||
// FIXME: See T260082 for a more complete description of cause and deeper fix
|
||||
$missingContent = ( !empty( $cDp->empty ) || trim( $refDmw->body->extsrc ?? '' ) === '' );
|
||||
|
@ -333,7 +338,7 @@ class References extends ExtensionTagHandler {
|
|||
// Keep the first content to compare multiple <ref>s with the same name.
|
||||
if ( $ref->contentId === null && !$missingContent ) {
|
||||
$ref->contentId = $contentId;
|
||||
$ref->dir = strtolower( $refDmw->attrs->dir ?? '' );
|
||||
$ref->dir = $refDir;
|
||||
} else {
|
||||
DOMCompat::remove( $c );
|
||||
$extApi->clearContentDOM( $contentId );
|
||||
|
|
Loading…
Reference in a new issue