Skip to content

Commit

Permalink
Encode binary strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Nov 29, 2024
1 parent 0b584f8 commit 21f5cf7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Service/CallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public function call(

$time_end = microtime(true);

$body = $response->getBody()->getContents();

// Let create the data array
$data = [
'request' => [
Expand All @@ -263,7 +265,7 @@ public function call(
'size' => $response->getBody()->getSize(),
'remoteIp' => $response->getHeaderLine('X-Real-IP') ?: $response->getHeaderLine('X-Forwarded-For') ?: null,
'headers' => $response->getHeaders(),
'body' => $response->getBody()->getContents(),
'body' => mb_check_encoding(value: $body, encoding: 'UTF-8') !== false ? $body : base64_encode($body),
]
];

Expand Down
43 changes: 43 additions & 0 deletions lib/Settings/OpenConnectorAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace OCA\OpenConnector\Settings;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;

class OpenConnectorAdmin implements ISettings {
private IL10N $l;
private IConfig $config;

public function __construct(IConfig $config, IL10N $l) {
$this->config = $config;
$this->l = $l;
}

/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'mySetting' => $this->config->getSystemValue('open_connector_setting', true),
];

return new TemplateResponse('openconnector', 'settings/admin', $parameters, '');
}

public function getSection() {
return 'openconnector'; // Name of the previously created section.
}

/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 10;
}
}

0 comments on commit 21f5cf7

Please sign in to comment.