| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\ConfirmEdit\SimpleCaptcha; |
| 4 |
|
| 5 |
use MailAddress; |
| 6 |
use MediaWiki\Api\ApiBase; |
| 7 |
use MediaWiki\Api\ApiEditPage; |
| 8 |
use MediaWiki\Auth\AuthenticationRequest; |
| 9 |
use MediaWiki\Cache\CacheKeyHelper; |
| 10 |
use MediaWiki\Config\Config; |
| 11 |
use MediaWiki\Config\ConfigException; |
| 12 |
use MediaWiki\Content\Content; |
| 13 |
use MediaWiki\Content\TextContent; |
| 14 |
use MediaWiki\Context\IContextSource; |
| 15 |
use MediaWiki\Context\RequestContext; |
| 16 |
use MediaWiki\EditPage\EditPage; |
| 17 |
use MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest; |
| 18 |
use MediaWiki\Extension\ConfirmEdit\CaptchaTriggers; |
| 19 |
use MediaWiki\Extension\ConfirmEdit\Hooks\HookRunner; |
| 20 |
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaStore; |
| 21 |
use MediaWiki\ExternalLinks\ExternalLinksLookup; |
| 22 |
use MediaWiki\ExternalLinks\LinkFilter; |
| 23 |
use MediaWiki\HTMLForm\HTMLForm; |
| 24 |
use MediaWiki\MediaWikiServices; |
| 25 |
use MediaWiki\Message\Message; |
| 26 |
use MediaWiki\Output\OutputPage; |
| 27 |
use MediaWiki\Parser\ParserOptions; |
| 28 |
use MediaWiki\Registration\ExtensionRegistry; |
| 29 |
use MediaWiki\Request\ContentSecurityPolicy; |
| 30 |
use MediaWiki\Request\WebRequest; |
| 31 |
use MediaWiki\Revision\RevisionAccessException; |
| 32 |
use MediaWiki\Revision\SlotRecord; |
| 33 |
use MediaWiki\Status\Status; |
| 34 |
use MediaWiki\Title\Title; |
| 35 |
use MediaWiki\User\User; |
| 36 |
use OOUI\FieldLayout; |
| 37 |
use OOUI\HiddenInputWidget; |
| 38 |
use OOUI\NumberInputWidget; |
| 39 |
use UnexpectedValueException; |
| 40 |
use Wikimedia\IPUtils; |
| 41 |
use Wikimedia\Rdbms\IDBAccessObject; |
| 42 |
use WikiPage; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
class SimpleCaptcha { |
| 48 |
|
| 49 |
protected static $messagePrefix = 'captcha-'; |
| 50 |
|
| 51 |
|
| 52 |
private bool $forceShowCaptcha = false; |
| 53 |
|
| 54 |
|
| 55 |
private ?bool $captchaSolved = null; |
| 56 |
|
| 57 |
|
| 58 |
private bool $editFilterMergedContentHandlerCalled = false; |
| 59 |
|
| 60 |
|
| 61 |
private $activatedCaptchas = []; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
protected $action; |
| 69 |
|
| 70 |
|
| 71 |
protected $trigger; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public function setAction( $action ) { |
| 77 |
$this->action = $action; |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public function setTrigger( $trigger ) { |
| 84 |
$this->trigger = $trigger; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public function getError() { |
| 93 |
return null; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public function getCaptcha() { |
| 103 |
$a = random_int( 0, 100 ); |
| 104 |
$b = random_int( 0, 10 ); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
$op = random_int( 0, 1 ) ? '+' : '−'; |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
$test = "$a$op$b"; |
| 113 |
$answer = ( $op == '+' ) ? ( $a + $b ) : ( $a - $b ); |
| 114 |
return [ 'question' => $test, 'answer' => $answer ]; |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
public function getActivatedCaptchas() { |
| 122 |
return $this->activatedCaptchas; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
protected function addCaptchaAPI( &$resultArr ) { |
| 129 |
$captcha = $this->getCaptcha(); |
| 130 |
$index = $this->storeCaptcha( $captcha ); |
| 131 |
$resultArr['captcha'] = $this->describeCaptchaType(); |
| 132 |
$resultArr['captcha']['id'] = $index; |
| 133 |
$resultArr['captcha']['question'] = $captcha['question']; |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
public function describeCaptchaType() { |
| 142 |
return [ |
| 143 |
'type' => 'simple', |
| 144 |
'mime' => 'text/plain', |
| 145 |
]; |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
public function getFormInformation( $tabIndex = 1 ) { |
| 178 |
$captcha = $this->getCaptcha(); |
| 179 |
$index = $this->storeCaptcha( $captcha ); |
| 180 |
|
| 181 |
return [ |
| 182 |
'html' => |
| 183 |
new FieldLayout( |
| 184 |
new NumberInputWidget( [ |
| 185 |
'name' => 'wpCaptchaWord', |
| 186 |
'classes' => [ 'simplecaptcha-answer' ], |
| 187 |
'id' => 'wpCaptchaWord', |
| 188 |
'autocomplete' => 'off', |
| 189 |
|
| 190 |
'tabIndex' => $tabIndex |
| 191 |
] ), |
| 192 |
[ |
| 193 |
'align' => 'left', |
| 194 |
'label' => $captcha['question'] . ' = ', |
| 195 |
'classes' => [ 'simplecaptcha-field' ], |
| 196 |
] |
| 197 |
) . |
| 198 |
new HiddenInputWidget( [ |
| 199 |
'name' => 'wpCaptchaId', |
| 200 |
'id' => 'wpCaptchaId', |
| 201 |
'value' => $index |
| 202 |
] ), |
| 203 |
'modulestyles' => [ |
| 204 |
'ext.confirmEdit.simpleCaptcha' |
| 205 |
] |
| 206 |
]; |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
public static function getCSPUrls() { |
| 213 |
return []; |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
public static function addCSPSources( ContentSecurityPolicy $csp ) { |
| 224 |
foreach ( static::getCSPUrls() as $src ) { |
| 225 |
$csp->addScriptSrc( $src ); |
| 226 |
$csp->addStyleSrc( $src ); |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
public function addFormToOutput( OutputPage $out, $tabIndex = 1 ) { |
| 238 |
$this->addFormInformationToOutput( $out, $this->getFormInformation( $tabIndex ) ); |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
public function addFormInformationToOutput( OutputPage $out, array $formInformation ) { |
| 249 |
static::addCSPSources( $out->getCSP() ); |
| 250 |
|
| 251 |
if ( !$formInformation ) { |
| 252 |
return; |
| 253 |
} |
| 254 |
if ( isset( $formInformation['html'] ) ) { |
| 255 |
$out->addHTML( $formInformation['html'] ); |
| 256 |
} |
| 257 |
if ( isset( $formInformation['modules'] ) ) { |
| 258 |
$out->addModules( $formInformation['modules'] ); |
| 259 |
} |
| 260 |
if ( isset( $formInformation['modulestyles'] ) ) { |
| 261 |
$out->addModuleStyles( $formInformation['modulestyles'] ); |
| 262 |
} |
| 263 |
if ( isset( $formInformation['headitems'] ) ) { |
| 264 |
$out->addHeadItems( $formInformation['headitems'] ); |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
public function getCaptchaInfo( $captchaData, $id ) { |
| 274 |
return array_key_exists( 'question', $captchaData ) ? ( $captchaData['question'] . ' =' ) : ''; |
| 275 |
} |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
public function showEditFormFields( EditPage $editPage, OutputPage $out ) { |
| 283 |
$out->enableOOUI(); |
| 284 |
$page = $editPage->getArticle()->getPage(); |
| 285 |
$key = CacheKeyHelper::getKeyForPage( $page ); |
| 286 |
if ( !isset( $this->activatedCaptchas[$key] ) ) { |
| 287 |
return; |
| 288 |
} |
| 289 |
|
| 290 |
if ( $this->action !== 'edit' ) { |
| 291 |
unset( $this->activatedCaptchas[$key] ); |
| 292 |
$out->addHTML( $this->getMessage( $this->action )->parseAsBlock() ); |
| 293 |
$this->addFormToOutput( $out ); |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
public function editShowCaptcha( $editPage ) { |
| 302 |
$context = $editPage->getArticle()->getContext(); |
| 303 |
$page = $editPage->getArticle()->getPage(); |
| 304 |
$out = $context->getOutput(); |
| 305 |
$key = CacheKeyHelper::getKeyForPage( $page ); |
| 306 |
if ( isset( $this->activatedCaptchas[$key] ) || |
| 307 |
$this->shouldCheck( $page, '', '', $context ) |
| 308 |
) { |
| 309 |
$out->addHTML( $this->getMessage( $this->action )->parseAsBlock() ); |
| 310 |
$this->addFormToOutput( $out ); |
| 311 |
} |
| 312 |
unset( $this->activatedCaptchas[$key] ); |
| 313 |
} |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
public function getMessage( $action ) { |
| 323 |
|
| 324 |
|
| 325 |
$name = static::$messagePrefix . $action; |
| 326 |
$msg = wfMessage( $name ); |
| 327 |
|
| 328 |
|
| 329 |
return $msg->isDisabled() ? wfMessage( static::$messagePrefix . 'edit' ) : $msg; |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
public function injectEmailUser( HTMLForm $form ) { |
| 339 |
$out = $form->getOutput(); |
| 340 |
$user = $form->getUser(); |
| 341 |
if ( $this->triggersCaptcha( CaptchaTriggers::SENDEMAIL ) ) { |
| 342 |
$this->action = 'sendemail'; |
| 343 |
if ( $this->canSkipCaptcha( $user, $form->getConfig() ) ) { |
| 344 |
return true; |
| 345 |
} |
| 346 |
$formInformation = $this->getFormInformation(); |
| 347 |
$formMetainfo = $formInformation; |
| 348 |
unset( $formMetainfo['html'] ); |
| 349 |
$this->addFormInformationToOutput( $out, $formMetainfo ); |
| 350 |
$form->addFooterHtml( |
| 351 |
"<div class='captcha'>" . |
| 352 |
$this->getMessage( 'sendemail' )->parseAsBlock() . |
| 353 |
$formInformation['html'] . |
| 354 |
"</div>\n" ); |
| 355 |
} |
| 356 |
return true; |
| 357 |
} |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
private function canIPBypassCaptcha() { |
| 368 |
global $wgCaptchaWhitelistIP, $wgCaptchaBypassIPs, $wgRequest; |
| 369 |
$ip = $wgRequest->getIP(); |
| 370 |
|
| 371 |
|
| 372 |
if ( $wgCaptchaWhitelistIP && IPUtils::isInRanges( $ip, $wgCaptchaWhitelistIP ) ) { |
| 373 |
return true; |
| 374 |
} |
| 375 |
|
| 376 |
if ( $wgCaptchaBypassIPs && IPUtils::isInRanges( $ip, $wgCaptchaBypassIPs ) ) { |
| 377 |
return true; |
| 378 |
} |
| 379 |
|
| 380 |
$msg = wfMessage( 'captcha-ip-whitelist' )->inContentLanguage(); |
| 381 |
if ( !$msg->isDisabled() ) { |
| 382 |
$allowedIPs = $this->getWikiIPBypassList( $msg ); |
| 383 |
if ( IPUtils::isInRanges( $ip, $allowedIPs ) ) { |
| 384 |
return true; |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
return false; |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
private function getWikiIPBypassList( Message $msg ) { |
| 398 |
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); |
| 399 |
$cacheKey = $cache->makeKey( 'confirmedit', 'ipbypasslist' ); |
| 400 |
|
| 401 |
$cached = $cache->get( $cacheKey ); |
| 402 |
if ( $cached !== false ) { |
| 403 |
return $cached; |
| 404 |
} |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
$list = $this->buildValidIPs( |
| 409 |
explode( "\n", $msg->plain() ) |
| 410 |
); |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
$cache->set( $cacheKey, $list, 86400 ); |
| 415 |
|
| 416 |
return $list; |
| 417 |
} |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
private function buildValidIPs( array $input ) { |
| 431 |
|
| 432 |
$ips = array_map( 'trim', $input ); |
| 433 |
$ips = array_filter( $ips ); |
| 434 |
|
| 435 |
$validIPs = []; |
| 436 |
foreach ( $ips as $ip ) { |
| 437 |
if ( IPUtils::isIPAddress( $ip ) ) { |
| 438 |
$validIPs[] = $ip; |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
return $validIPs; |
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
protected function keyMatch( $answer, $info ) { |
| 456 |
return $answer == $info['answer']; |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
public function captchaTriggers( $title, $action ) { |
| 468 |
return $this->triggersCaptcha( $action, $title ); |
| 469 |
} |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
public function triggersCaptcha( $action, $title = null ) { |
| 482 |
|
| 483 |
if ( $this->isCaptchaSolved() ) { |
| 484 |
return false; |
| 485 |
} |
| 486 |
|
| 487 |
global $wgCaptchaTriggers, $wgCaptchaTriggersOnNamespace; |
| 488 |
|
| 489 |
$result = false; |
| 490 |
$triggers = $wgCaptchaTriggers; |
| 491 |
$attributeCaptchaTriggers = ExtensionRegistry::getInstance() |
| 492 |
->getAttribute( CaptchaTriggers::EXT_REG_ATTRIBUTE_NAME ); |
| 493 |
if ( is_array( $attributeCaptchaTriggers ) ) { |
| 494 |
$triggers += $attributeCaptchaTriggers; |
| 495 |
} |
| 496 |
|
| 497 |
if ( isset( $triggers[$action] ) ) { |
| 498 |
$result = $triggers[$action]; |
| 499 |
} |
| 500 |
|
| 501 |
if ( |
| 502 |
$title !== null && |
| 503 |
isset( $wgCaptchaTriggersOnNamespace[$title->getNamespace()][$action] ) |
| 504 |
) { |
| 505 |
$result = $wgCaptchaTriggersOnNamespace[$title->getNamespace()][$action]; |
| 506 |
} |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
if ( $this->shouldForceShowCaptcha() ) { |
| 511 |
return true; |
| 512 |
} |
| 513 |
|
| 514 |
$hookRunner = new HookRunner( |
| 515 |
MediaWikiServices::getInstance()->getHookContainer() |
| 516 |
); |
| 517 |
$hookRunner->onConfirmEditTriggersCaptcha( $action, $title, $result ); |
| 518 |
|
| 519 |
return $result; |
| 520 |
} |
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
public function shouldCheck( WikiPage $page, $content, $section, $context, $oldtext = null ) { |
| 532 |
if ( !$context instanceof IContextSource ) { |
| 533 |
$context = RequestContext::getMain(); |
| 534 |
} |
| 535 |
|
| 536 |
$request = $context->getRequest(); |
| 537 |
$user = $context->getUser(); |
| 538 |
|
| 539 |
if ( $this->canSkipCaptcha( $user, $context->getConfig() ) ) { |
| 540 |
return false; |
| 541 |
} |
| 542 |
|
| 543 |
$title = $page->getTitle(); |
| 544 |
$this->trigger = ''; |
| 545 |
|
| 546 |
if ( $content instanceof Content ) { |
| 547 |
if ( $content->getModel() == CONTENT_MODEL_WIKITEXT ) { |
| 548 |
$newtext = $content->getNativeData(); |
| 549 |
} else { |
| 550 |
$newtext = null; |
| 551 |
} |
| 552 |
$isEmpty = $content->isEmpty(); |
| 553 |
} else { |
| 554 |
$newtext = $content; |
| 555 |
$isEmpty = $content === ''; |
| 556 |
} |
| 557 |
|
| 558 |
if ( $this->triggersCaptcha( 'edit', $title ) ) { |
| 559 |
|
| 560 |
$this->trigger = sprintf( "edit trigger by '%s' at [[%s]]", |
| 561 |
$user->getName(), |
| 562 |
$title->getPrefixedText() ); |
| 563 |
$this->action = 'edit'; |
| 564 |
wfDebug( "ConfirmEdit: checking all edits...\n" ); |
| 565 |
return true; |
| 566 |
} |
| 567 |
|
| 568 |
if ( $this->triggersCaptcha( 'create', $title ) && !$title->exists() ) { |
| 569 |
|
| 570 |
$this->trigger = sprintf( "Create trigger by '%s' at [[%s]]", |
| 571 |
$user->getName(), |
| 572 |
$title->getPrefixedText() ); |
| 573 |
$this->action = 'create'; |
| 574 |
wfDebug( "ConfirmEdit: checking on page creation...\n" ); |
| 575 |
return true; |
| 576 |
} |
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
if ( !$request->wasPosted() ) { |
| 581 |
wfDebug( |
| 582 |
"ConfirmEdit: request not posted, assuming that no content will be saved -> no CAPTCHA check" |
| 583 |
); |
| 584 |
return false; |
| 585 |
} |
| 586 |
|
| 587 |
if ( !$isEmpty && $this->triggersCaptcha( 'addurl', $title ) ) { |
| 588 |
|
| 589 |
if ( $content instanceof Content ) { |
| 590 |
|
| 591 |
$oldLinks = ExternalLinksLookup::getExternalLinksForPage( |
| 592 |
$title->getArticleID(), |
| 593 |
MediaWikiServices::getInstance() |
| 594 |
->getConnectionProvider() |
| 595 |
->getReplicaDatabase(), |
| 596 |
__METHOD__ |
| 597 |
); |
| 598 |
|
| 599 |
$editInfo = $page->prepareContentForEdit( $content, null, $user ); |
| 600 |
if ( $editInfo->output ) { |
| 601 |
$newLinks = LinkFilter::getIndexedUrlsNonReversed( |
| 602 |
array_keys( $editInfo->output->getExternalLinks() ) |
| 603 |
); |
| 604 |
} else { |
| 605 |
$newLinks = []; |
| 606 |
} |
| 607 |
} else { |
| 608 |
|
| 609 |
$oldtext ??= $this->loadText( $title, $section ); |
| 610 |
$oldLinks = $this->findLinks( $title, $oldtext ); |
| 611 |
$newLinks = $this->findLinks( $title, $newtext ); |
| 612 |
} |
| 613 |
|
| 614 |
$unknownLinks = array_filter( $newLinks, [ $this, 'filterLink' ] ); |
| 615 |
$addedLinks = array_diff( $unknownLinks, $oldLinks ); |
| 616 |
$numLinks = count( $addedLinks ); |
| 617 |
|
| 618 |
if ( $numLinks > 0 ) { |
| 619 |
$this->trigger = sprintf( "%dx url trigger by '%s' at [[%s]]: %s", |
| 620 |
$numLinks, |
| 621 |
$user->getName(), |
| 622 |
$title->getPrefixedText(), |
| 623 |
implode( ", ", $addedLinks ) ); |
| 624 |
$this->action = 'addurl'; |
| 625 |
return true; |
| 626 |
} |
| 627 |
} |
| 628 |
|
| 629 |
global $wgCaptchaRegexes; |
| 630 |
if ( $newtext !== null && $wgCaptchaRegexes ) { |
| 631 |
if ( !is_array( $wgCaptchaRegexes ) ) { |
| 632 |
throw new UnexpectedValueException( |
| 633 |
'$wgCaptchaRegexes is required to be an array, ' . get_debug_type( $wgCaptchaRegexes ) . ' given.' |
| 634 |
); |
| 635 |
} |
| 636 |
|
| 637 |
$oldtext ??= $this->loadText( $title, $section ); |
| 638 |
|
| 639 |
foreach ( $wgCaptchaRegexes as $regex ) { |
| 640 |
$newMatches = []; |
| 641 |
if ( preg_match_all( $regex, $newtext, $newMatches ) ) { |
| 642 |
$oldMatches = []; |
| 643 |
preg_match_all( $regex, $oldtext, $oldMatches ); |
| 644 |
|
| 645 |
$addedMatches = array_diff( $newMatches[0], $oldMatches[0] ); |
| 646 |
|
| 647 |
$numHits = count( $addedMatches ); |
| 648 |
if ( $numHits > 0 ) { |
| 649 |
$this->trigger = sprintf( "%dx %s at [[%s]]: %s", |
| 650 |
$numHits, |
| 651 |
$regex, |
| 652 |
$user->getName(), |
| 653 |
$title->getPrefixedText(), |
| 654 |
implode( ", ", $addedMatches ) ); |
| 655 |
$this->action = 'edit'; |
| 656 |
return true; |
| 657 |
} |
| 658 |
} |
| 659 |
} |
| 660 |
} |
| 661 |
|
| 662 |
return false; |
| 663 |
} |
| 664 |
|
| 665 |
public function isCaptchaSolved(): ?bool { |
| 666 |
return $this->captchaSolved; |
| 667 |
} |
| 668 |
|
| 669 |
protected function setCaptchaSolved( ?bool $captchaSolved ): void { |
| 670 |
$this->captchaSolved = $captchaSolved; |
| 671 |
} |
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
public function shouldForceShowCaptcha(): bool { |
| 679 |
return $this->forceShowCaptcha; |
| 680 |
} |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
public function setForceShowCaptcha( bool $forceShowCaptcha ): void { |
| 689 |
$this->forceShowCaptcha = $forceShowCaptcha; |
| 690 |
} |
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
public function editFilterMergedContentHandlerAlreadyInvoked(): bool { |
| 697 |
return $this->editFilterMergedContentHandlerCalled; |
| 698 |
} |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
public function setEditFilterMergedContentHandlerInvoked(): void { |
| 705 |
$this->editFilterMergedContentHandlerCalled = true; |
| 706 |
} |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
private function filterLink( $url ) { |
| 714 |
global $wgCaptchaWhitelist, $wgCaptchaIgnoredUrls; |
| 715 |
static $regexes = null; |
| 716 |
|
| 717 |
if ( $regexes === null ) { |
| 718 |
$source = wfMessage( 'captcha-addurl-whitelist' )->inContentLanguage(); |
| 719 |
|
| 720 |
$regexes = $source->isDisabled() |
| 721 |
? [] |
| 722 |
: $this->buildRegexes( explode( "\n", $source->plain() ) ); |
| 723 |
|
| 724 |
|
| 725 |
if ( $wgCaptchaWhitelist !== false ) { |
| 726 |
array_unshift( $regexes, $wgCaptchaWhitelist ); |
| 727 |
} |
| 728 |
if ( $wgCaptchaIgnoredUrls !== false ) { |
| 729 |
array_unshift( $regexes, $wgCaptchaIgnoredUrls ); |
| 730 |
} |
| 731 |
} |
| 732 |
|
| 733 |
foreach ( $regexes as $regex ) { |
| 734 |
if ( preg_match( $regex, $url ) ) { |
| 735 |
return false; |
| 736 |
} |
| 737 |
} |
| 738 |
|
| 739 |
return true; |
| 740 |
} |
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
private function buildRegexes( $lines ) { |
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
$lines = array_filter( array_map( 'trim', preg_replace( '/#.*$/', '', $lines ) ) ); |
| 754 |
|
| 755 |
|
| 756 |
if ( count( $lines ) === 0 ) { |
| 757 |
wfDebug( "No lines\n" ); |
| 758 |
return []; |
| 759 |
} else { |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
$regexes = []; |
| 765 |
$regexStart = [ |
| 766 |
'normal' => '/^(?:https?:)?\/\/+[a-z0-9_\-.]*(?:', |
| 767 |
'noprotocol' => '/^(?:', |
| 768 |
]; |
| 769 |
$regexEnd = [ |
| 770 |
'normal' => ')/Si', |
| 771 |
'noprotocol' => ')/Si', |
| 772 |
]; |
| 773 |
$regexMax = 4096; |
| 774 |
$build = []; |
| 775 |
foreach ( $lines as $line ) { |
| 776 |
|
| 777 |
$options = []; |
| 778 |
if ( preg_match( '/^(.*?)\s*<([^<>]*)>$/', $line, $matches ) ) { |
| 779 |
if ( $matches[1] === '' ) { |
| 780 |
wfDebug( "Line with empty regex\n" ); |
| 781 |
continue; |
| 782 |
} |
| 783 |
$line = $matches[1]; |
| 784 |
$opts = preg_split( '/\s*\|\s*/', trim( $matches[2] ) ); |
| 785 |
foreach ( $opts as $opt ) { |
| 786 |
$opt = strtolower( $opt ); |
| 787 |
if ( $opt == 'noprotocol' ) { |
| 788 |
$options['noprotocol'] = true; |
| 789 |
} |
| 790 |
} |
| 791 |
} |
| 792 |
|
| 793 |
$key = isset( $options['noprotocol'] ) ? 'noprotocol' : 'normal'; |
| 794 |
|
| 795 |
|
| 796 |
if ( !isset( $build[$key] ) ) { |
| 797 |
$build[$key] = $line; |
| 798 |
} elseif ( strlen( $build[$key] ) + strlen( $line ) > $regexMax ) { |
| 799 |
$regexes[] = $regexStart[$key] . |
| 800 |
str_replace( '/', '\/', preg_replace( '|\\\*/|', '/', $build[$key] ) ) . |
| 801 |
$regexEnd[$key]; |
| 802 |
$build[$key] = $line; |
| 803 |
} else { |
| 804 |
$build[$key] .= '|' . $line; |
| 805 |
} |
| 806 |
} |
| 807 |
foreach ( $build as $key => $value ) { |
| 808 |
$regexes[] = $regexStart[$key] . |
| 809 |
str_replace( '/', '\/', preg_replace( '|\\\*/|', '/', $value ) ) . |
| 810 |
$regexEnd[$key]; |
| 811 |
} |
| 812 |
return $regexes; |
| 813 |
} |
| 814 |
} |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
private function doConfirmEdit( |
| 826 |
WikiPage $page, |
| 827 |
$newtext, |
| 828 |
$section, |
| 829 |
IContextSource $context, |
| 830 |
User $user |
| 831 |
) { |
| 832 |
global $wgRequest; |
| 833 |
$request = $context->getRequest(); |
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
if ( $request->getVal( 'captchaid' ) ) { |
| 838 |
$request->setVal( 'wpCaptchaId', $request->getVal( 'captchaid' ) ); |
| 839 |
$wgRequest->setVal( 'wpCaptchaId', $request->getVal( 'captchaid' ) ); |
| 840 |
} |
| 841 |
if ( $request->getVal( 'captchaword' ) ) { |
| 842 |
$request->setVal( 'wpCaptchaWord', $request->getVal( 'captchaword' ) ); |
| 843 |
$wgRequest->setVal( 'wpCaptchaWord', $request->getVal( 'captchaword' ) ); |
| 844 |
} |
| 845 |
if ( $this->shouldCheck( $page, $newtext, $section, $context ) ) { |
| 846 |
return $this->passCaptchaLimitedFromRequest( $wgRequest, $user ); |
| 847 |
} else { |
| 848 |
wfDebug( "ConfirmEdit: no need to show captcha.\n" ); |
| 849 |
return true; |
| 850 |
} |
| 851 |
} |
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
public function confirmEditMerged( $context, $content, $status, $summary, $user, $minorEdit ) { |
| 864 |
$title = $context->getTitle(); |
| 865 |
if ( !( $title->canExist() ) ) { |
| 866 |
|
| 867 |
|
| 868 |
$title = $context->getTitle(); |
| 869 |
if ( $title instanceof Title ) { |
| 870 |
$title = $title->getFullText(); |
| 871 |
} else { |
| 872 |
|
| 873 |
$title = 'unknown'; |
| 874 |
} |
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
wfDebug( __METHOD__ . ': Skipped ConfirmEdit check: No WikiPage for title ' . $title ); |
| 879 |
return true; |
| 880 |
} |
| 881 |
$page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $title ); |
| 882 |
if ( !$this->doConfirmEdit( $page, $content, '', $context, $user ) ) { |
| 883 |
$status->value = EditPage::AS_HOOK_ERROR_EXPECTED; |
| 884 |
$status->statusData = []; |
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
if ( $this->action === 'edit' ) { |
| 889 |
|
| 890 |
$message = 'captcha-edit-fail'; |
| 891 |
if ( $this->shouldForceShowCaptcha() ) { |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
$message = 'captcha-edit'; |
| 896 |
[ $_index, $word ] = $this->getCaptchaParamsFromRequest( |
| 897 |
RequestContext::getMain()->getRequest() |
| 898 |
); |
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
if ( $word ) { |
| 903 |
$message = 'captcha-edit-fail'; |
| 904 |
} |
| 905 |
} |
| 906 |
$status->fatal( $message ); |
| 907 |
} |
| 908 |
$this->addCaptchaAPI( $status->statusData ); |
| 909 |
$key = CacheKeyHelper::getKeyForPage( $page ); |
| 910 |
$this->activatedCaptchas[$key] = true; |
| 911 |
return false; |
| 912 |
} |
| 913 |
return true; |
| 914 |
} |
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
public function needCreateAccountCaptcha( User $creatingUser ) { |
| 924 |
if ( $this->triggersCaptcha( CaptchaTriggers::CREATE_ACCOUNT ) ) { |
| 925 |
if ( $this->canSkipCaptcha( $creatingUser, |
| 926 |
\MediaWiki\MediaWikiServices::getInstance()->getMainConfig() ) ) { |
| 927 |
return false; |
| 928 |
} |
| 929 |
return true; |
| 930 |
} |
| 931 |
return false; |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
public function confirmEmailUser( $from, $to, $subject, $text, &$error ) { |
| 944 |
global $wgRequest; |
| 945 |
|
| 946 |
$user = RequestContext::getMain()->getUser(); |
| 947 |
if ( $this->triggersCaptcha( CaptchaTriggers::SENDEMAIL ) ) { |
| 948 |
if ( $this->canSkipCaptcha( $user, |
| 949 |
\MediaWiki\MediaWikiServices::getInstance()->getMainConfig() ) ) { |
| 950 |
return true; |
| 951 |
} |
| 952 |
|
| 953 |
if ( defined( 'MW_API' ) ) { |
| 954 |
|
| 955 |
|
| 956 |
$error = Status::newFatal( 'captcha-disabledinapi' ); |
| 957 |
return false; |
| 958 |
} |
| 959 |
$this->trigger = "{$user->getName()} sending email"; |
| 960 |
if ( !$this->passCaptchaLimitedFromRequest( $wgRequest, $user ) ) { |
| 961 |
$error = Status::newFatal( 'captcha-sendemail-fail' ); |
| 962 |
return false; |
| 963 |
} |
| 964 |
} |
| 965 |
return true; |
| 966 |
} |
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
protected function isAPICaptchaModule( $module ) { |
| 973 |
return $module instanceof ApiEditPage; |
| 974 |
} |
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
public function apiGetAllowedParams( ApiBase $module, &$params, $flags ) { |
| 983 |
if ( $this->isAPICaptchaModule( $module ) ) { |
| 984 |
$params['captchaword'] = [ |
| 985 |
ApiBase::PARAM_HELP_MSG => 'captcha-apihelp-param-captchaword', |
| 986 |
]; |
| 987 |
$params['captchaid'] = [ |
| 988 |
ApiBase::PARAM_HELP_MSG => 'captcha-apihelp-param-captchaid', |
| 989 |
]; |
| 990 |
} |
| 991 |
|
| 992 |
return true; |
| 993 |
} |
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
public function passCaptchaLimitedFromRequest( WebRequest $request, User $user ) { |
| 1004 |
[ $index, $word ] = $this->getCaptchaParamsFromRequest( $request ); |
| 1005 |
return $this->passCaptchaLimited( $index, $word, $user ); |
| 1006 |
} |
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
protected function getCaptchaParamsFromRequest( WebRequest $request ) { |
| 1013 |
$index = $request->getVal( 'wpCaptchaId' ); |
| 1014 |
$word = $request->getVal( 'wpCaptchaWord' ); |
| 1015 |
return [ $index, $word ]; |
| 1016 |
} |
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
public function passCaptchaLimited( $index, $word, User $user ) { |
| 1029 |
|
| 1030 |
if ( $user->pingLimiter( 'badcaptcha', 0 ) ) { |
| 1031 |
|
| 1032 |
$this->log( 'User reached RateLimit, preventing action' ); |
| 1033 |
return false; |
| 1034 |
} |
| 1035 |
|
| 1036 |
if ( $this->passCaptcha( $index, $word ) ) { |
| 1037 |
return true; |
| 1038 |
} |
| 1039 |
|
| 1040 |
|
| 1041 |
$user->pingLimiter( 'badcaptcha' ); |
| 1042 |
return false; |
| 1043 |
} |
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
public function passCaptchaFromRequest( WebRequest $request, User $user ) { |
| 1053 |
[ $index, $word ] = $this->getCaptchaParamsFromRequest( $request ); |
| 1054 |
return $this->passCaptcha( $index, $word ); |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
protected function passCaptcha( $index, $word ) { |
| 1065 |
|
| 1066 |
|
| 1067 |
if ( $this->isCaptchaSolved() !== null ) { |
| 1068 |
return (bool)$this->isCaptchaSolved(); |
| 1069 |
} |
| 1070 |
|
| 1071 |
if ( $index === null ) { |
| 1072 |
$this->log( "new captcha session" ); |
| 1073 |
|
| 1074 |
return false; |
| 1075 |
} |
| 1076 |
|
| 1077 |
$info = $this->retrieveCaptcha( $index ); |
| 1078 |
if ( $info ) { |
| 1079 |
if ( $this->keyMatch( $word, $info ) ) { |
| 1080 |
$this->log( "passed" ); |
| 1081 |
$this->clearCaptcha( $index ); |
| 1082 |
$this->setCaptchaSolved( true ); |
| 1083 |
return true; |
| 1084 |
} else { |
| 1085 |
$this->clearCaptcha( $index ); |
| 1086 |
$this->log( "bad form input" ); |
| 1087 |
$this->setCaptchaSolved( false ); |
| 1088 |
return false; |
| 1089 |
} |
| 1090 |
} else { |
| 1091 |
$this->log( "new captcha session" ); |
| 1092 |
return false; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
protected function log( $message ) { |
| 1101 |
wfDebugLog( |
| 1102 |
'captcha', |
| 1103 |
'ConfirmEdit: ' . $message . '; {trigger}', |
| 1104 |
'all', |
| 1105 |
[ 'trigger' => $this->trigger ] |
| 1106 |
); |
| 1107 |
} |
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
public function storeCaptcha( $info ) { |
| 1121 |
if ( !isset( $info['index'] ) ) { |
| 1122 |
|
| 1123 |
$info['index'] = (string)random_int( 0, PHP_INT_MAX ); |
| 1124 |
} |
| 1125 |
CaptchaStore::get()->store( $info['index'], $info ); |
| 1126 |
return $info['index']; |
| 1127 |
} |
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
public function retrieveCaptcha( $index ) { |
| 1135 |
return CaptchaStore::get()->retrieve( $index ); |
| 1136 |
} |
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
public function clearCaptcha( $index ) { |
| 1144 |
CaptchaStore::get()->clear( $index ); |
| 1145 |
} |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
private function loadText( $title, $section, $flags = IDBAccessObject::READ_LATEST ) { |
| 1156 |
$revRecord = MediaWikiServices::getInstance() |
| 1157 |
->getRevisionLookup() |
| 1158 |
->getRevisionByTitle( $title, 0, $flags ); |
| 1159 |
|
| 1160 |
if ( $revRecord === null ) { |
| 1161 |
return ""; |
| 1162 |
} |
| 1163 |
|
| 1164 |
try { |
| 1165 |
$content = $revRecord->getContent( SlotRecord::MAIN ); |
| 1166 |
} catch ( RevisionAccessException $e ) { |
| 1167 |
return ''; |
| 1168 |
} |
| 1169 |
|
| 1170 |
$text = ( $content instanceof TextContent ) ? $content->getText() : null; |
| 1171 |
if ( $section !== '' ) { |
| 1172 |
return MediaWikiServices::getInstance()->getParser() |
| 1173 |
->getSection( $text, $section ); |
| 1174 |
} |
| 1175 |
|
| 1176 |
return $text; |
| 1177 |
} |
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
private function findLinks( $title, $text ) { |
| 1186 |
$parser = MediaWikiServices::getInstance()->getParser(); |
| 1187 |
$user = $parser->getUserIdentity(); |
| 1188 |
$options = new ParserOptions( $user ); |
| 1189 |
$text = $parser->preSaveTransform( $text, $title, $user, $options ); |
| 1190 |
$out = $parser->parse( $text, $title, $options ); |
| 1191 |
|
| 1192 |
return array_keys( $out->getExternalLinks() ); |
| 1193 |
} |
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
public function showHelp() { |
| 1199 |
$context = RequestContext::getMain(); |
| 1200 |
$out = $context->getOutput(); |
| 1201 |
$out->setPageTitleMsg( $context->msg( 'captchahelp-title' ) ); |
| 1202 |
$out->addWikiMsg( 'captchahelp-text' ); |
| 1203 |
if ( CaptchaStore::get()->cookiesNeeded() ) { |
| 1204 |
$out->addWikiMsg( 'captchahelp-cookies-needed' ); |
| 1205 |
} |
| 1206 |
} |
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
public function createAuthenticationRequest() { |
| 1212 |
$captchaData = $this->getCaptcha(); |
| 1213 |
$id = $this->storeCaptcha( $captchaData ); |
| 1214 |
return new CaptchaAuthenticationRequest( $id, $captchaData ); |
| 1215 |
} |
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
public function onAuthChangeFormFields( |
| 1225 |
array $requests, array $fieldInfo, array &$formDescriptor, $action |
| 1226 |
) { |
| 1227 |
$req = AuthenticationRequest::getRequestByClass( $requests, |
| 1228 |
CaptchaAuthenticationRequest::class ); |
| 1229 |
if ( !$req ) { |
| 1230 |
return; |
| 1231 |
} |
| 1232 |
|
| 1233 |
$formDescriptor['captchaWord'] = [ |
| 1234 |
'label-message' => null, |
| 1235 |
'autocomplete' => false, |
| 1236 |
'persistent' => false, |
| 1237 |
'required' => true, |
| 1238 |
] + $formDescriptor['captchaWord']; |
| 1239 |
} |
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
public function canSkipCaptcha( $user, Config $config ) { |
| 1249 |
$allowConfirmEmail = $config->get( 'AllowConfirmedEmail' ); |
| 1250 |
|
| 1251 |
if ( $user->isAllowed( 'skipcaptcha' ) ) { |
| 1252 |
wfDebug( "ConfirmEdit: user group allows skipping captcha\n" ); |
| 1253 |
return true; |
| 1254 |
} |
| 1255 |
|
| 1256 |
if ( $this->canIPBypassCaptcha() ) { |
| 1257 |
wfDebug( "ConfirmEdit: user IP can bypass captcha" ); |
| 1258 |
return true; |
| 1259 |
} |
| 1260 |
if ( $user->isSystemUser() ) { |
| 1261 |
wfDebug( "ConfirmEdit: system user skips captcha\n" ); |
| 1262 |
return true; |
| 1263 |
} |
| 1264 |
|
| 1265 |
if ( $allowConfirmEmail && $user->isEmailConfirmed() ) { |
| 1266 |
wfDebug( "ConfirmEdit: user has confirmed mail, skipping captcha\n" ); |
| 1267 |
return true; |
| 1268 |
} |
| 1269 |
|
| 1270 |
return false; |
| 1271 |
} |
| 1272 |
} |