From 17944c01ea8a9d03dd3b69a00f9c93df3210f85c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 24 Aug 2021 11:30:11 -0400 Subject: [PATCH 1/2] Allow a GuzzleResponse body to be queried more than once - Using `StreamInterface->getContents` left the stream index at the end of the stream, which made every subsequent call to `getBody()` return empty string - Using `StreamInterface->__toString()` magic method correctly seek the stream to the start before reading --- src/Network/GuzzleResponse.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Network/GuzzleResponse.php b/src/Network/GuzzleResponse.php index b68f2e8435..3b41f6f654 100644 --- a/src/Network/GuzzleResponse.php +++ b/src/Network/GuzzleResponse.php @@ -147,8 +147,8 @@ class GuzzleResponse extends Response implements IHTTPResult, ResponseInterface } /// @todo - fix mismatching use of "getBody()" as string here and parent "getBody()" as streaminterface - public function getBody() + public function getBody(): string { - return parent::getBody()->getContents(); + return (string) parent::getBody(); } } From 7a8d800024b297fd8cffe35a5398a52c2388bd19 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 24 Aug 2021 11:32:27 -0400 Subject: [PATCH 2/2] Add probe support to `@user@domain.tld` search string format --- mod/follow.php | 3 +-- src/Console/Contact.php | 3 +++ src/Module/Debug/Probe.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/follow.php b/mod/follow.php index 075e58d091..09201bed16 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -60,8 +60,7 @@ function follow_content(App $a) $uid = local_user(); - // Issue 4815: Silently removing a prefixing @ - $url = ltrim(Strings::escapeTags(trim($_REQUEST['url'] ?? '')), '@!'); + $url = Probe::cleanURI(trim($_REQUEST['url'] ?? '')); // Issue 6874: Allow remote following from Peertube if (strpos($url, 'acct:') === 0) { diff --git a/src/Console/Contact.php b/src/Console/Contact.php index ba65c00251..9dfcf13925 100644 --- a/src/Console/Contact.php +++ b/src/Console/Contact.php @@ -25,6 +25,7 @@ use Console_Table; use Friendica\App; use Friendica\Model\Contact as ContactModel; use Friendica\Model\User as UserModel; +use Friendica\Network\Probe; use Friendica\Util\Temporal; use RuntimeException; use Seld\CliPrompt\CliPrompt; @@ -153,6 +154,8 @@ HELP; } } + $url = Probe::cleanURI($url); + $contact = ContactModel::getByURLForUser($url, $user['uid']); if (!empty($contact)) { throw new RuntimeException('Contact already exists'); diff --git a/src/Module/Debug/Probe.php b/src/Module/Debug/Probe.php index 86aa4afd11..6c2891c0be 100644 --- a/src/Module/Debug/Probe.php +++ b/src/Module/Debug/Probe.php @@ -44,6 +44,7 @@ class Probe extends BaseModule $res = ''; if (!empty($addr)) { + $addr = NetworkProbe::cleanURI($addr); $res = NetworkProbe::uri($addr, '', 0); $res = print_r($res, true); }