Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3
- nightly
env:
- COMPOSER_REQUIRE=""
- COMPOSER_REQUIRE="composer require masterminds/html5"
matrix:
fast_finish: true
allow_failures:
- php: nightly
install:
- $COMPOSER_REQUIRE
before_script: composer install
5 changes: 1 addition & 4 deletions Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1090,14 +1090,11 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
}

// Check for u-photo
if (!array_key_exists('photo', $return) && !$is_backcompat) {

if (!array_key_exists('photo', $return) && !in_array('u-', $prefixes) && !$has_nested_mf && !$is_backcompat) {
$photo = $this->parseImpliedPhoto($e);

if ($photo !== false) {
$return['photo'][] = $photo;
}

}

// Do we need to imply a url property?
Expand Down
22 changes: 22 additions & 0 deletions tests/Mf2/ParseImpliedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,27 @@ public function testNoImgSrcImpliedName() {
$this->assertArrayHasKey('name', $result['items'][0]['properties']);
$this->assertEquals('My Name', $result['items'][0]['properties']['name'][0]);
}

/**
* @see https://github.com/microformats/php-mf2/issues/198
*/
public function testNoImpliedPhotoWhenExplicitUProperty() {
$input = '<div class="h-card"> <span class="p-org">Organization Name</span> <img src="/logo.png" class="u-logo" alt=""> </div>';
$result = Mf2\parse($input);

$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}

/**
* @see https://github.com/microformats/php-mf2/issues/198
*/
public function testNoImpliedPhotoWhenNestedMicroformat() {
$input = '<div class="h-entry"> <img src="/photo.jpg" alt=""> <div class="p-author h-card"> <span class="p-name">Alice</span> <span class="p-org">Organization Name</span> <img src="/logo.png" class="u-logo" alt=""> </div> </div>';
$result = Mf2\parse($input);

$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
$this->assertArrayHasKey('author', $result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']['author'][0]['properties']);
}
}