Skip to content

Commit 0953dc0

Browse files
committed
improve parsing
1 parent 73f0e9f commit 0953dc0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

includes/Handler/class-mf2.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,13 @@ public function find_representative_item( $mf_array, $target, $ignore_hcards = t
473473
'content' === $key &&
474474
! empty( $value['html'] ) &&
475475
is_string( $value['html'] ) &&
476-
preg_match_all( '/<a\b[^>]*href\s*=\s*["\']?' . preg_quote( $target, '/' ) . '["\']/i', $value['html'], $context )
476+
preg_match_all( '/<a[^>]*href\s*=\s*["\']?' . preg_quote( $target, '/' ) . '["\']?/i', $value['html'] )
477477
) {
478478
return $item;
479479
} elseif (
480480
'summary' === $key &&
481481
is_string( $value ) &&
482-
preg_match_all( '/<a\b[^>]*href\s*=\s*["\']?' . preg_quote( $target, '/' ) . '["\']/i', $value, $context )
482+
preg_match_all( '/<a[^>]*href\s*=\s*["\']?' . preg_quote( $target, '/' ) . '["\']?/i', $value )
483483
) {
484484
return $item;
485485
}
@@ -815,13 +815,13 @@ protected function get_response_type( $entry, $mf_array, $target ) {
815815
'content' === $obj_key &&
816816
! empty( $obj_value['html'] ) &&
817817
is_string( $obj_value['html'] ) &&
818-
preg_match_all( '/<a[^>]+?' . preg_quote( $target, '/' ) . '[^>]*>([^>]+?)<\/a>/i', $obj_value['html'], $context )
818+
preg_match_all( '/<a[^>]*href\s*=\s*["\']?' . preg_quote( $target, '/' ) . '["\']?/i', $obj_value['html'] )
819819
) {
820820
return $classes[ $key ];
821821
} elseif (
822822
'summary' === $obj_key &&
823823
is_string( $obj_value ) &&
824-
preg_match_all( '/<a[^>]+?' . preg_quote( $target, '/' ) . '[^>]*>([^>]+?)<\/a>/i', $obj_value, $context )
824+
preg_match_all( '/<a[^>]*href\s*=\s*["\']?' . preg_quote( $target, '/' ) . '["\']?/i', $obj_value )
825825
) {
826826
return $classes[ $key ];
827827
}

tests/data/mf2/brid-gy-mastodon.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"author": {
3-
"name": "elena",
3+
"name": "Elena Rossini on GoToSocial ⁂",
44
"url": "https://aseachange.com/users/elena"
55
},
66
"response_type": "mention"

0 commit comments

Comments
 (0)