Skip to content

Commit 9655e20

Browse files
committed
fix: use hostname as author of webmentions when not author name present
1 parent 32bf322 commit 9655e20

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

lib/WebmentionReceiver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ public function saveWebmention(array $webmention, $page)
1818
$autoPublish = option('mauricerenck.komments.webmentions.publish', true);
1919
$spamlevel = 0;
2020

21+
$webmentionHost = parse_url($webmention['source'], PHP_URL_HOST);
22+
2123
$comment = $storage->createComment(
2224
id: $id,
2325
pageUuid: $page->uuid(),
2426
parentId: '',
2527
type: $webmention['type'],
2628
content: $webmention['content'],
27-
authorName: $webmention['author']['name'] ?? 'unknown',
29+
authorName: $webmention['author']['name'] ?? $webmentionHost,
2830
authorAvatar: $webmention['author']['avatar'] ?? '',
2931
authorEmail: null,
3032
authorUrl: $webmention['source'],

vendor/autoload.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
echo $err;
1515
}
1616
}
17-
trigger_error(
18-
$err,
19-
E_USER_ERROR
20-
);
17+
throw new RuntimeException($err);
2118
}
2219

2320
require_once __DIR__ . '/composer/autoload_real.php';

vendor/composer/InstalledVersions.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
*/
2727
class InstalledVersions
2828
{
29+
/**
30+
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
31+
* @internal
32+
*/
33+
private static $selfDir = null;
34+
2935
/**
3036
* @var mixed[]|null
3137
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
@@ -322,6 +328,18 @@ public static function reload($data)
322328
self::$installedIsLocalDir = false;
323329
}
324330

331+
/**
332+
* @return string
333+
*/
334+
private static function getSelfDir()
335+
{
336+
if (self::$selfDir === null) {
337+
self::$selfDir = strtr(__DIR__, '\\', '/');
338+
}
339+
340+
return self::$selfDir;
341+
}
342+
325343
/**
326344
* @return array[]
327345
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
@@ -336,7 +354,7 @@ private static function getInstalled()
336354
$copiedLocalDir = false;
337355

338356
if (self::$canGetVendors) {
339-
$selfDir = strtr(__DIR__, '\\', '/');
357+
$selfDir = self::getSelfDir();
340358
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
341359
$vendorDir = strtr($vendorDir, '\\', '/');
342360
if (isset(self::$installedByVendor[$vendorDir])) {

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'mauricerenck/komments',
4-
'pretty_version' => '3.0.0',
5-
'version' => '3.0.0.0',
4+
'pretty_version' => '3.0.3',
5+
'version' => '3.0.3.0',
66
'reference' => null,
77
'type' => 'kirby-plugin',
88
'install_path' => __DIR__ . '/../../',
@@ -29,8 +29,8 @@
2929
'dev_requirement' => false,
3030
),
3131
'mauricerenck/komments' => array(
32-
'pretty_version' => '3.0.0',
33-
'version' => '3.0.0.0',
32+
'pretty_version' => '3.0.3',
33+
'version' => '3.0.3.0',
3434
'reference' => null,
3535
'type' => 'kirby-plugin',
3636
'install_path' => __DIR__ . '/../../',

0 commit comments

Comments
 (0)