Allow OpenGraph RFDa meta tags
authorAmir Sarabadani <Ladsgroup@gmail.com>
Tue, 24 Jan 2017 12:01:47 +0000 (15:31 +0330)
committerAmir Sarabadani <Ladsgroup@gmail.com>
Wed, 25 Jan 2017 18:19:55 +0000 (21:49 +0330)
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

includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php

index fd28f4a..91fc75c 100644 (file)
@@ -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';
                        }
index 371731b..d2494da 100644 (file)
@@ -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( '<meta http-equiv="expires" content="0"/>', $links );
                $this->assertContains( '<meta name="keywords" content="first"/>', $links );
                $this->assertContains( '<meta name="keywords" content="second"/>', $links );
+               $this->assertContains( '<meta property="og:title" content="Ta-duh"/>', $links );
                $this->assertArrayNotHasKey( 'meta-robots', $links );
        }