From: Amir Sarabadani Date: Tue, 24 Jan 2017 12:01:47 +0000 (+0330) Subject: Allow OpenGraph RFDa meta tags X-Git-Tag: 1.31.0-rc.0~4209^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=a1e2f07784c1d7a53e58b7d6d5b9391c5509e958;p=lhc%2Fweb%2Fwiklou.git Allow OpenGraph RFDa meta tags See: http://stackoverflow.com/questions/22350105/whats-the-difference-between-meta-name-and-meta-property And https://developers.facebook.com/docs/sharing/webmasters#markup Bug: T51859 Change-Id: Ie8fd697e8588435a69f02e779038ae5a11d67be6 --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index fd28f4a1d3..91fc75c9bd 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3259,9 +3259,11 @@ class OutputPage extends ContextSource { } foreach ( $this->mMetatags as $tag ) { - if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) { + if ( strncasecmp( $tag[0], 'http:', 5 ) === 0 ) { $a = 'http-equiv'; $tag[0] = substr( $tag[0], 5 ); + } elseif ( strncasecmp( $tag[0], 'og:', 3 ) === 0 ) { + $a = 'property'; } else { $a = 'name'; } diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 371731b257..d2494dacd9 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -22,11 +22,13 @@ class OutputPageTest extends MediaWikiTestCase { $outputPage->addMeta( 'http:expires', '0' ); $outputPage->addMeta( 'keywords', 'first' ); $outputPage->addMeta( 'keywords', 'second' ); + $outputPage->addMeta( 'og:title', 'Ta-duh' ); $expected = [ [ 'http:expires', '0' ], [ 'keywords', 'first' ], [ 'keywords', 'second' ], + [ 'og:title', 'Ta-duh' ], ]; $this->assertSame( $expected, $outputPage->getMetaTags() ); @@ -34,6 +36,7 @@ class OutputPageTest extends MediaWikiTestCase { $this->assertContains( '', $links ); $this->assertContains( '', $links ); $this->assertContains( '', $links ); + $this->assertContains( '', $links ); $this->assertArrayNotHasKey( 'meta-robots', $links ); }