Code Duplication    Length = 5-8 lines in 2 locations

includes/upload/UploadBase.php 2 locations

@@ 1424-1431 (lines=8) @@
1421
				&& strpos( $value, 'data:' ) !== 0
1422
				&& strpos( $value, '#' ) !== 0
1423
			) {
1424
				if ( !( $strippedElement === 'a'
1425
					&& preg_match( '!^https?://!i', $value ) )
1426
				) {
1427
					wfDebug( __METHOD__ . ": Found href attribute <$strippedElement "
1428
						. "'$attrib'='$value' in uploaded file.\n" );
1429
1430
					return [ 'uploaded-href-attribute-svg', $strippedElement, $attrib, $value ];
1431
				}
1432
			}
1433
1434
			# only allow data: targets that should be safe. This prevents vectors like,
@@ 1442-1446 (lines=5) @@
1439
				$parameters = '(?>;[a-zA-Z0-9\!#$&\'*+.^_`{|}~-]+=(?>[a-zA-Z0-9\!#$&\'*+.^_`{|}~-]+|"(?>[\0-\x0c\x0e-\x21\x23-\x5b\x5d-\x7f]+|\\\\[\0-\x7f])*"))*(?:;base64)?';
1440
				// @codingStandardsIgnoreEnd
1441
1442
				if ( !preg_match( "!^data:\s*image/(gif|jpeg|jpg|png)$parameters,!i", $value ) ) {
1443
					wfDebug( __METHOD__ . ": Found href to unwhitelisted data: uri "
1444
						. "\"<$strippedElement '$attrib'='$value'...\" in uploaded file.\n" );
1445
					return [ 'uploaded-href-unsafe-target-svg', $strippedElement, $attrib, $value ];
1446
				}
1447
			}
1448
1449
			# Change href with animate from (http://html5sec.org/#137).