diff options
109 files changed, 16824 insertions, 1101 deletions
@@ -1,3 +1,103 @@ +Hubzilla 10.4 (2025-??-??) + - Minor cleanup to the account functions and added tests + - Do not sign (request-target) on response + - Start verifying incoming RFC9421 HTTP signatures + - Convert geo URIs into clickable links + - Allow geo URIs in url bbcode tags + - Cleanup obsolete and unused functions + - Remove unused Xref module + - Make sure we have the keys before attempting to sign with JcsEddsa2022 + - Implement lazy loading of toplevel comments + - Update german help files + - Add App::$page_layouts attribute for comanche + - Refactor and fix numerous issues in guess_image_type() + - Add tests for Widget\Messages + - Refactor cache_embeds daemon to be called with uuid (instead of item id) so that it will only be processed once + - Add avif support for php-gd + - Exclude Add/Remove items from network nouveau query + - Always preload images and remove pre image preload setting + - Introduce per channel conversation mode setting + - Add API docs for the observer file + - Move observer helper functions to separate source + - Introduce helper functions to access the various fields of the xchan stored in App::$observer + - Refactor item_normal() to accept an owner uid + - Implement reply modal if comment replies are enabled + - Streamline wording conversation > comment > reply + - Streamline default ordering to created date + - Default to threaded conversation mode + - Implement lazy loading of reactions + - Do not store dismissed create activities in dreport + - Refactor mod item to deprecate x() and use $_POST instead of $_REQUEST superglobal + - Improved styling for dreport module + - Start deprecation of the function x() + - Minor cleanup and refactor for Web/Router + - Minor cleanup and refactor for Lib/Webserver + - Set App::$query_string from from server.request_uri instead of server.query_string because the latter will mostly be urldecoded by the server already + - Refactor language selector + - Extend message filter to support until=2025-04-18 20:49:00 for date/time based filtering and add tests + - Extend message filter to deal with && and || conditions and add tests + - Prevent storing files/folder with filenames exceeding their max name length + - Deal with attachment of type link + - Revert translation of network to stream + - Updated debian install script + - Add suport for strong bbcode tag + - Change photo.filename to type text for new installs + - Provide methods to get mid and uuid from activity object + - Minor update for boxy schema + - Update composer libs + - Reorganize emojis and allow custom site emojis + - Change item.obj and item.target to mediumtext for mysql new installs + - Move jot related functions to jot-header and some cleanup + - Port photo selector to vanilla javascript + - Enable photo selector for comments if OCAP access is enabled + - Add :hubzilla: emoji + - Add :zot: emoji + - Include unapproved connections in deliverable_abook_xchans() + - Port showHideComments() to vanilla javascript + - Disable browser rotating image based on EXIF metadata + + Bugfixes + - Fix issue where item_wall was not set for article and card item types + - Fix first created account was not necessarily the admin account + - Fix notice not emited on failed login + - Fix intro notifications not handled via /notify/view and hence not marked seen + - Fix undefined static function in Zot6Handler + - Fix missing return in Render\Theme::current + - Fix announce source title (addr) not correct + - Fix offset calculation if element position is relative + - Fix autosave for comments + - Fix notfication issue with update activities + - Fix sess_data not updated to mediumtext in mysql schema file + - Fix title and summary converted to bbcode + - Fix preloading images if dom element is not yet in page + - Fix verb and hash for notifications + - Fix notification button for medium screen size (right aside collapsed) + - Fix new result set created for updated results (dreport) + - Fix regex to catch codeblocks with params like class in smilies() + - Fix term.imgurl not stored in item_store_update() + - Fix folder names are not URL escaped in Files app (issue #1903) + - Fix stephenhill/base58 PHP warnings + - Fix color bbcode markup + - Fix video poster display issue + - Fix relayed emoji reactions + - Fix some javascript errors on mobile devices + - Fix our own activities visible in unseen forum notifications + - Fix duplicated head_get_icon() + + Addons + - Pubcrawl: remove unused force note setting + - Flashcards: major refactor and added functionality + - Superblock: refactor and new siteblock option for admins + - Cart: fix issue related to HTTP3 + - Pubcrawl: avoid DB lookup if not valid AS request in mod followers and mod following + - Photocache: implement prefetch via cache_embeds daemon and minor refactor + - Articles: fix Add/Remove activities not dismissed in channel activities query + - Cards: fix Add/Remove activities not dismissed in channel activities query + - Diaspora: make sure item_thread_top is set for reshares (info for filters) + - Gallery: fix missing folder field from query + - Pubcrawl: update mod ap_probe to show a visual representation if applicable + + Hubzilla 10.2.3 (2025-04-11) - Fix bogus merge from 10.2.2 release diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index ebf866a3b..296129ea2 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -3350,10 +3350,10 @@ class Activity { if (array_key_exists('startTime', $act) && strpos($act['startTime'], -1, 1) === 'Z') { $adjust = true; $event['adjust'] = 1; - $event['dtstart'] = datetime_convert('UTC', 'UTC', $event['startTime'] . (($adjust) ? '' : 'Z')); + $event['dtstart'] = datetime_convert('UTC', 'UTC', $act['startTime'] . (($adjust) ? '' : 'Z')); } if (array_key_exists('endTime', $act)) { - $event['dtend'] = datetime_convert('UTC', 'UTC', $event['endTime'] . (($adjust) ? '' : 'Z')); + $event['dtend'] = datetime_convert('UTC', 'UTC', $act['endTime'] . (($adjust) ? '' : 'Z')); } else { $event['nofinish'] = true; diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php index fa3d61244..3f2db88c3 100644 --- a/Zotlabs/Lib/MessageFilter.php +++ b/Zotlabs/Lib/MessageFilter.php @@ -8,8 +8,8 @@ class MessageFilter { public static function evaluate($item, $incl, $excl) { - $text = prepare_text($item['body'],((isset($item['mimetype'])) ? $item['mimetype'] : 'text/bbcode')); - $text = html2plain(($item['title']) ? $item['title'] . ' ' . $text : $text); + $text = prepare_text($item['body'], ((isset($item['mimetype'])) ? $item['mimetype'] : 'text/bbcode')); + $text = html2plain((!empty($item['title'])) ? $item['title'] . ' ' . $text : $text); $lang = null; if ((strpos($incl, 'lang=') !== false) || (strpos($excl, 'lang=') !== false) || (strpos($incl, 'lang!=') !== false) || (strpos($excl, 'lang!=') !== false)) { diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index f73f25d5f..e35a611d0 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -85,7 +85,7 @@ class Channel extends Controller { $headers = [ 'Content-Type' => 'application/x-zot+json', 'Digest' => HTTPSig::generate_digest_header($data), - '(request-target)' => strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'] + 'Date' => datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T') ]; $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel)); diff --git a/Zotlabs/Module/Home.php b/Zotlabs/Module/Home.php index 39a1c8ea4..0dec432d0 100644 --- a/Zotlabs/Module/Home.php +++ b/Zotlabs/Module/Home.php @@ -24,9 +24,13 @@ class Home extends Controller { $key = Config::Get('system', 'prvkey'); $ret = json_encode(Libzot::site_info()); - $headers = ['Content-Type' => 'application/x-zot+json', 'Digest' => HTTPSig::generate_digest_header($ret)]; - $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; - $h = HTTPSig::create_sig($headers, $key, z_root()); + $headers = [ + 'Content-Type' => 'application/x-zot+json', + 'Digest' => HTTPSig::generate_digest_header($ret), + 'Date' => datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T') + ]; + + $h = HTTPSig::create_sig($headers, $key, z_root()); HTTPSig::set_headers($h); echo $ret; diff --git a/Zotlabs/Module/Id.php b/Zotlabs/Module/Id.php index e08568d00..004cad6e7 100644 --- a/Zotlabs/Module/Id.php +++ b/Zotlabs/Module/Id.php @@ -6,8 +6,8 @@ namespace Zotlabs\Module; * * Controller for responding to x-zot: protocol requests * x-zot:_jkfRG85nJ-714zn-LW_VbTFW8jSjGAhAydOcJzHxqHkvEHWG2E0RbA_pbch-h4R63RG1YJZifaNzgccoLa3MQ/453c1678-1a79-4af7-ab65-6b012f6cab77 - * - */ + * + */ use Zotlabs\Lib\Activity; use Zotlabs\Lib\ActivityStreams; @@ -104,7 +104,7 @@ class Id extends Controller { $headers['Content-Type'] = 'application/x-zot+json' ; $ret = json_encode($x, JSON_UNESCAPED_SLASHES); $headers['Digest'] = HTTPSig::generate_digest_header($ret); - $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; + $headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'); $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan)); HTTPSig::set_headers($h); echo $ret; diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index e164d6be3..83e8d609e 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -176,7 +176,7 @@ class Item extends Controller { $return_path = ((!empty($_POST['return'])) ? $_POST['return'] : ''); $preview = ((!empty($_POST['preview'])) ? intval($_POST['preview']) : 0); $categories = ((!empty($_POST['category'])) ? escape_tags($_POST['category']) : ''); - $webpage = ((!empty($_POST['webpage'])) ? intval($_POST['webpage']) : 0); + $item_type = ((!empty($_POST['webpage'])) ? intval($_POST['webpage']) : ITEM_TYPE_POST); $item_obscured = ((!empty($_POST['obscured'])) ? intval($_POST['obscured']) : 0); $item_delayed = ((!empty($_POST['delayed'])) ? intval($_POST['delayed']) : 0); $pagetitle = ((!empty($_POST['pagetitle'])) ? escape_tags($_POST['pagetitle']) : ''); @@ -314,7 +314,7 @@ class Item extends Controller { } } else { - if (!perm_is_allowed($profile_uid, $observer['xchan_hash'], ($webpage) ? 'write_pages' : 'post_wall')) { + if (!perm_is_allowed($profile_uid, $observer['xchan_hash'], (intval($item_type) === ITEM_TYPE_POST) ? 'post_wall' : 'write_pages')) { notice(t('Permission denied.') . EOL); if ($api_source) return (['success' => false, 'message' => 'permission denied']); @@ -426,16 +426,20 @@ class Item extends Controller { $view_policy = \Zotlabs\Access\PermissionLimits::Get($channel['channel_id'], 'view_stream'); $comment_policy = \Zotlabs\Access\PermissionLimits::Get($channel['channel_id'], 'post_comments'); - $public_policy = ((!empty($_POST['public_policy'])) ? escape_tags($_POST['public_policy']) : map_scope($view_policy, true)); - if ($webpage) - $public_policy = ''; - if ($public_policy) + $public_policy = ''; + + if (intval($item_type) === ITEM_TYPE_POST) { + $public_policy = ((!empty($_POST['public_policy'])) ? escape_tags($_POST['public_policy']) : map_scope($view_policy, true)); + } + + if ($public_policy) { $private = 1; + } if ($orig_post) { $private = 0; - // webpages are allowed to change ACLs after the fact. Normal conversation items aren't. - if ($webpage) { + // Normal conversation items are not allowed to change ACL. + if (intval($item_type) !== ITEM_TYPE_POST) { $acl->set_from_array($_POST); } else { @@ -531,7 +535,7 @@ class Item extends Controller { $private = intval($parent_item['item_private']); $public_policy = $parent_item['public_policy']; $owner_hash = $parent_item['owner_xchan']; - $webpage = $parent_item['item_type']; + $item_type = $parent_item['item_type']; } @@ -592,7 +596,7 @@ class Item extends Controller { $is_group = get_pconfig($profile_uid, 'system', 'group_actor'); - if ($is_group && $walltowall && !$walltowall_comment && !$webpage) { + if ($is_group && $walltowall && !$walltowall_comment && (intval($item_type) === ITEM_TYPE_POST)) { $groupww = true; $str_contact_allow = $owner_xchan['xchan_hash']; $str_group_allow = ''; @@ -799,15 +803,13 @@ class Item extends Controller { // determine if this is a wall post + if (in_array($item_type, [ITEM_TYPE_POST, ITEM_TYPE_CARD, ITEM_TYPE_ARTICLE])) { + $item_wall = 1; + } + if ($parent) { $item_wall = $parent_item['item_wall']; } - else { - if (!$webpage) { - $item_wall = 1; - } - } - if ($moderated) { $item_blocked = ITEM_MODERATED; @@ -930,7 +932,7 @@ class Item extends Controller { $datarray['item_unseen'] = intval($item_unseen); $datarray['item_wall'] = intval($item_wall); $datarray['item_origin'] = intval($item_origin); - $datarray['item_type'] = $webpage; + $datarray['item_type'] = $item_type; $datarray['item_private'] = intval($private); $datarray['item_thread_top'] = intval($item_thread_top); $datarray['item_starred'] = intval($item_starred); @@ -1025,8 +1027,8 @@ class Item extends Controller { if (mb_strlen($datarray['title']) > 191) $datarray['title'] = mb_substr($datarray['title'], 0, 191); - if ($webpage) { - IConfig::Set($datarray, 'system', webpage_to_namespace($webpage), + if (intval($item_type) !== ITEM_TYPE_POST) { + IConfig::Set($datarray, 'system', item_type_to_namespace($item_type), (($pagetitle) ? $pagetitle : basename($datarray['mid'])), true); } elseif ($namespace) { diff --git a/Zotlabs/Module/Login.php b/Zotlabs/Module/Login.php index 269990a54..f5a83a91a 100644 --- a/Zotlabs/Module/Login.php +++ b/Zotlabs/Module/Login.php @@ -5,10 +5,17 @@ namespace Zotlabs\Module; class Login extends \Zotlabs\Web\Controller { function get() { - if(local_channel()) + if (local_channel()) { goaway(z_root()); - if(remote_channel() && $_SESSION['atoken']) + } + + if (remote_channel() && $_SESSION['atoken']) { goaway(z_root()); + } + + if (!empty($_GET['retry'])) { + notice( t('Login failed.') . EOL ); + } $o = '<div class="generic-content-wrapper">'; $o .= '<div class="section-title-wrapper">'; diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 7c289ff5f..ce56ae46b 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -2,6 +2,7 @@ namespace Zotlabs\Web; +use App; use DateTime; use DateTimeZone; use Zotlabs\Lib\Activity; @@ -11,6 +12,7 @@ use Zotlabs\Lib\Keyutils; use Zotlabs\Lib\Webfinger; use Zotlabs\Lib\Zotfinger; use Zotlabs\Lib\Libzot; +use HttpSignature\HttpMessageSigner; /** * @brief Implements HTTP Signatures per draft-cavage-http-signatures-10. @@ -88,7 +90,7 @@ class HTTPSig { // See draft-cavage-http-signatures-10 - static function verify($data, $key = '', $keytype = '') { + public static function verify($data, $key = '', $keytype = '') { $body = $data; $headers = null; @@ -102,11 +104,49 @@ class HTTPSig { 'content_valid' => false ]; - $headers = self::find_headers($data, $body); - if (!$headers) + if (!$headers) { return $result; + } + + if (array_key_exists('signature-input', $headers) && array_key_exists('signature', $headers)) { + $found = preg_match('/keyid="(.*?)"/', $headers['signature-input'], $matches); + $keyId = ($found) ? $matches[1] : ''; + + if (!$keyId) { + return $result; + } + + $found = preg_match('/alg="(.*?)"/', $headers['signature-input'], $matches); + $alg = ($found) ? $matches[1] : null; + + $keyInfo = self::get_key($key, $keytype, $keyId); + $publicKey = $keyInfo['public_key']; + + $messageSigner = new HttpMessageSigner(); + + $messageSigner->setPublicKey($publicKey); + $messageSigner->setAlgorithm($alg); + $messageSigner->setKeyId($keyId); + + $messageSigner->setNonce(preg_match('/nonce="(.*?)"/', $headers['signature-input'], $matches) ? $matches[1] : ''); + $messageSigner->setTag(preg_match('/tag="(.*?)"/', $headers['signature-input'], $matches) ? $matches[1] : ''); + $messageSigner->setCreated(preg_match('/created=([0-9]+)/', $headers['signature-input'], $matches) ? $matches[1] : ''); + $messageSigner->setExpires(preg_match('/expires=([0-9]+)/', $headers['signature-input'], $matches) ? $matches[1] : ''); + + $verified = $messageSigner->verifyRequest(App::$request); + logger('verified (RFC9421): ' . (($verified) ? 'true' : 'false'), LOGGER_DEBUG); + + return [ + 'signer' => $keyId, + 'portable_id' => $keyInfo['portable_id'] ?? '', + 'header_signed' => true, + 'header_valid' => $verified, + 'content_signed' => array_key_exists('content-digest', $headers), + 'content_valid' => $verified + ]; + } if (is_array($body)) { btlogger('body is array:' . print_r($body, true)); diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index a59a509f2..89ef755d9 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -4,6 +4,7 @@ namespace Zotlabs\Web; use App; use Zotlabs\Lib\Text; +use GuzzleHttp\Psr7\ServerRequest; class WebServer { @@ -18,6 +19,7 @@ class WebServer { $installed = sys_boot(); + App::$request = ServerRequest::fromGlobals(); App::$language = get_best_language(); load_translation_table(App::$language, !$installed); @@ -70,7 +70,7 @@ require_once('include/security.php'); define('PLATFORM_NAME', 'hubzilla'); -define('STD_VERSION', '10.3.71'); +define('STD_VERSION', '10.5'); define('ZOT_REVISION', '6.0'); define('DB_UPDATE_VERSION', 1263); @@ -774,7 +774,7 @@ class miniApp { * */ class App { - + public static $request = null; public static $install = false; // true if we are installing the software public static $account = null; // account record of the logged-in account public static $channel = null; // channel record of the current channel of the logged-in account @@ -1802,26 +1802,6 @@ function shutdown() { } /** - * @brief Returns the entity id of locally logged in account or false. - * - * Returns numeric account_id if authenticated or 0. It is possible to be - * authenticated and not connected to a channel. - * - * @return int|bool account_id or false - */ -function get_account_id() { - if (isset($_SESSION['account_id'])) { - return intval($_SESSION['account_id']); - } - - if (App::$account) { - return intval(App::$account['account_id']); - } - - return false; -} - -/** * @brief Returns the entity id (channel_id) of locally logged in channel or false. * * Returns authenticated numeric channel_id if authenticated and connected to diff --git a/composer.json b/composer.json index 62793d7a5..539ed0a5d 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,8 @@ "stephenhill/base58": "^1.1", "mmccook/php-json-canonicalization-scheme": "^1.0", "scssphp/scssphp": "^2.0.1", - "twbs/bootstrap-icons": "^1.11" + "twbs/bootstrap-icons": "^1.11", + "macgirvin/http-message-signer": "^0.1.6" }, "require-dev": { "ext-yaml": "*", diff --git a/composer.lock b/composer.lock index edd07c234..ba3a1dbf9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,91 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2eb30d4399172ceafecf36238f69d828", + "content-hash": "8f1b58d772a2f4032a722d009de51fc4", "packages": [ { + "name": "bakame/http-structured-fields", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/bakame-php/http-structured-fields.git", + "reference": "d0fc193e5b173a4e90f2fa589d5b97b2b653b323" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bakame-php/http-structured-fields/zipball/d0fc193e5b173a4e90f2fa589d5b97b2b653b323", + "reference": "d0fc193e5b173a4e90f2fa589d5b97b2b653b323", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "bakame/aide-base32": "dev-main", + "friendsofphp/php-cs-fixer": "^3.65.0", + "httpwg/structured-field-tests": "*@dev", + "phpbench/phpbench": "^1.3.1", + "phpstan/phpstan": "^2.0.3", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpstan/phpstan-phpunit": "^2.0.1", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^10.5.38 || ^11.5.0", + "symfony/var-dumper": "^6.4.15 || ^v7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Bakame\\Http\\StructuredFields\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://github.com/nyamsprod/", + "role": "Developer" + } + ], + "description": "A PHP library that parses, validates and serializes HTTP structured fields according to RFC9561 and RFC8941", + "keywords": [ + "headers", + "http", + "http headers", + "http trailers", + "parser", + "rfc8941", + "rfc9651", + "serializer", + "structured fields", + "structured headers", + "structured trailers", + "structured values", + "trailers", + "validation" + ], + "support": { + "docs": "https://github.com/bakame-php/http-structured-fields", + "issues": "https://github.com/bakame-php/http-structured-fields/issues", + "source": "https://github.com/bakame-php/http-structured-fields" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2024-12-12T08:25:42+00:00" + }, + { "name": "blueimp/jquery-file-upload", "version": "v10.32.0", "source": { @@ -508,6 +590,122 @@ "time": "2024-11-01T03:51:45+00:00" }, { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2025-03-27T12:30:47+00:00" + }, + { "name": "jbroadway/urlify", "version": "1.2.5-stable", "source": { @@ -882,6 +1080,47 @@ "time": "2016-09-22T15:10:54+00:00" }, { + "name": "macgirvin/http-message-signer", + "version": "v0.1.7", + "source": { + "type": "git", + "url": "https://github.com/macgirvin/HTTP-Message-Signer.git", + "reference": "44db674fb750b4e4909cf1aeb3a18a4c68d938ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/macgirvin/HTTP-Message-Signer/zipball/44db674fb750b4e4909cf1aeb3a18a4c68d938ca", + "reference": "44db674fb750b4e4909cf1aeb3a18a4c68d938ca", + "shasum": "" + }, + "require": { + "bakame/http-structured-fields": "^2.0", + "ext-openssl": "*", + "guzzlehttp/psr7": "^2.0", + "php": "^8.1", + "psr/http-message": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "HttpSignature\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "RFC 9421 HTTP Message Signer and Verifier for PSR-7 requests", + "support": { + "issues": "https://github.com/macgirvin/HTTP-Message-Signer/issues", + "source": "https://github.com/macgirvin/HTTP-Message-Signer/tree/v0.1.7" + }, + "time": "2025-06-25T03:19:43+00:00" + }, + { "name": "michelf/php-markdown", "version": "2.0.0", "source": { @@ -1478,6 +1717,50 @@ "time": "2024-09-11T13:17:53+00:00" }, { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { "name": "ramsey/collection", "version": "2.1.1", "source": { diff --git a/include/account.php b/include/account.php index ad69b4d9a..0c07bd85f 100644 --- a/include/account.php +++ b/include/account.php @@ -17,10 +17,38 @@ require_once('include/crypto.php'); require_once('include/channel.php'); -function get_account_by_id($account_id) { - $r = q("select * from account where account_id = %d", - intval($account_id) - ); +/** + * Returns the id of a locally logged in account or false. + * + * Returns the numeric account id of the current session if authenticated, or + * false otherwise. + * + * @note It is possible to be authenticated, and not connected to a channel. + * + * @return int|false Numeric account id or false. + */ +function get_account_id(): int|false { + if (isset($_SESSION['account_id'])) { + return intval($_SESSION['account_id']); + } + + if (App::$account) { + return intval(App::$account['account_id']); + } + + return false; +} + +/** + * Get the account with the given id from the database. + * + * @param int $account_id The numeric id of the account to fetch. + * + * @return array|false An array containing the attributes of the requested + * account, or false if it could not be retreived. + */ +function get_account_by_id(int $account_id): array|false { + $r = q("select * from account where account_id = %d", $account_id); return (($r) ? $r[0] : false); } @@ -117,11 +145,16 @@ function check_account_invite($invite_code) { } function check_account_admin($arr) { - if(is_site_admin()) + if (is_site_admin()) { return true; + } + $admin_email = trim(Config::Get('system','admin_email')); - if(strlen($admin_email) && $admin_email === trim($arr['email'])) + + if (strlen($admin_email) && $admin_email === trim($arr['reg_email'])) { return true; + } + return false; } @@ -163,18 +196,18 @@ function create_account_from_register($arr) { if($default_service_class === false) $default_service_class = ''; - $roles = 0; - // prevent form hackery - if($roles & ACCOUNT_ROLE_ADMIN) { - $admin_result = check_account_admin($arr); - if(! $admin_result) { - $roles = 0; - } + // any accounts available ? + $total = q("SELECT COUNT(*) AS total FROM account"); + + if ($total && intval($total[0]['total']) === 0 && !check_account_admin($register[0])) { + logger('create_account: first account is not admin'); + $result['message'] = t('First account is not admin.'); + return $result; } - // any accounts available ? - $isa = q("SELECT COUNT(*) AS isa FROM account"); - if ($isa && $isa[0]['isa'] == 0) { + $roles = 0; + + if (check_account_admin($register[0])) { $roles = ACCOUNT_ROLE_ADMIN; } diff --git a/include/auth.php b/include/auth.php index 439f064e4..36a9043ce 100644 --- a/include/auth.php +++ b/include/auth.php @@ -353,9 +353,6 @@ else { elseif($atoken) { atoken_login($atoken); } - else { - notice( t('Failed authentication') . EOL); - } if(! ($account || $atoken)) { $error = 'authenticate: failed login attempt: ' . notags(trim($username)) . ' from IP ' . $_SERVER['REMOTE_ADDR']; @@ -364,8 +361,8 @@ else { $authlog = Config::Get('system', 'authlog'); if ($authlog) @file_put_contents($authlog, datetime_convert() . ':' . session_id() . ' ' . $error . "\n", FILE_APPEND); - notice( t('Login failed.') . EOL ); - goaway(z_root() . '/login'); + + goaway(z_root() . '/login?retry=1'); } // If the user specified to remember the authentication, then change the cookie diff --git a/include/bbcode.php b/include/bbcode.php index 2c8ef3f20..d5e1bafd9 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1190,7 +1190,7 @@ function bbcode($text, $options = []) { $cache = ((array_key_exists('cache',$options)) ? $options['cache'] : false); $newwin = ((array_key_exists('newwin',$options)) ? $options['newwin'] : true); - $target = (($newwin) ? ' target="_blank" ' : ''); + $target = (($newwin) ? 'target="_blank"' : ''); /** * @hooks bbcode_filter @@ -1332,21 +1332,31 @@ function bbcode($text, $options = []) { $text = str_replace('[observer.photo]','', $text); } - - // Perform URL Search - $urlchars = '[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]'; if (strpos($text,'http') !== false) { if($tryoembed) { $text = preg_replace_callback("/([^\]\='".'"'."\;\/]|^|\#\^)(https?\:\/\/$urlchars+)/ismu", 'tryoembed', $text); } - // Is this still desired? - // We already turn naked URLs into links during creation time cleanup_bbcode() + $text = preg_replace("/([^\]\='".'"'."\;\/]|^|\#\^)(https?\:\/\/$urlchars+)/ismu", '$1<a href="$2" ' . $target . ' rel="nofollow noopener">$2</a>', $text); } + // Turn naked geo URIs into clickable links + if (str_contains($text, 'geo:')) { + $text = preg_replace_callback( + '/([^\]\=\'";\/]|^|\#\^)(geo:([A-Za-z0-9:.,;_+\-?&=%]+)(?:\(([^)]+)\))?)/ismu', + function ($matches) { + $before = $matches[1]; + $geo_uri = $matches[2]; + $label = ((!empty($matches[4])) ? '📍' . urldecode($matches[4]) : $geo_uri); + return $before . '<a href="' . htmlspecialchars($geo_uri) . '" target="_blank" rel="nofollow noopener">' . htmlspecialchars($label) . '</a>'; + }, + $text + ); + } + $count = 0; while (strpos($text,'[/share]') !== false && $count < 10) { $text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism", 'bb_ShareAttributes', $text); @@ -1360,23 +1370,23 @@ function bbcode($text, $options = []) { } if (strpos($text,'[/url]') !== false) { - $text = preg_replace("/\#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); - $text = preg_replace("/\#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text); - $text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); - $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text); + $text = preg_replace("/\#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); + $text = preg_replace("/\#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text); + $text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); + $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text); } if (strpos($text,'[/zrl]') !== false) { - $text = preg_replace("/\#\^\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); - $text = preg_replace("/\#\^\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text); - $text = preg_replace("/\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); - $text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text); + $text = preg_replace("/\#\^\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); + $text = preg_replace("/\#\^\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text); + $text = preg_replace("/\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); + $text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text); } // Perform MAIL Search if (strpos($text,'[/mail]') !== false) { - $text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); - $text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text); + $text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); + $text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text); } @@ -1737,17 +1747,17 @@ function bbcode($text, $options = []) { // if video couldn't be embedded, link to it instead. if (strpos($text,'[/video]') !== false) { - $text = preg_replace("/\[video\](.*?)\[\/video\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); + $text = preg_replace("/\[video\](.*?)\[\/video\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); } if (strpos($text,'[/audio]') !== false) { - $text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); + $text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); } if (strpos($text,'[/zvideo]') !== false) { - $text = preg_replace("/\[zvideo\](.*?)\[\/zvideo\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); + $text = preg_replace("/\[zvideo\](.*?)\[\/zvideo\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); } if (strpos($text,'[/zaudio]') !== false) { - $text = preg_replace("/\[zaudio\](.*?)\[\/zaudio\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text); + $text = preg_replace("/\[zaudio\](.*?)\[\/zaudio\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text); } // oembed tag @@ -1813,9 +1823,13 @@ function bbcode($text, $options = []) { $text = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism", '<$1$2=$3&$4>', $text); // This is subtle - it's an XSS filter. It only accepts links with a protocol scheme and where - // the scheme begins with z (zhttp), h (http(s)), f (ftp(s)), m (mailto), t (tel) and named anchors. + // the scheme begins with http:, https:, mailto:, tel:, geo: and named anchors. - $text = preg_replace("/\<(.*?)(src|href)=\"[^zhfmt#](.*?)\>/ism", '<$1$2="">', $text); + $text = preg_replace( + '/(<[^>]*?\b(?:src|href)\s*=\s*([\'"])\s*)(?!https?:|geo:|mailto:|tel:|#)[^\'"]*?\2/iu', + '$1$2$2', + $text + ); $text = bb_replace_images($text, $saved_images); diff --git a/include/event.php b/include/event.php index b83a733b8..39d0c49c2 100644 --- a/include/event.php +++ b/include/event.php @@ -106,7 +106,7 @@ function format_event_obj($jobject) { $title = $object['name'] ?? ''; $content = html2bbcode($object['content']); - if (strpos($object['source']['content'], '[/event-description]') !== false) { + if (isset($object['source']['content']) && strpos($object['source']['content'], '[/event-description]') !== false) { $bbdescription = []; preg_match("/\[event\-description\](.*?)\[\/event\-description\]/ism", $object['source']['content'], $bbdescription); $content = $bbdescription[1]; diff --git a/include/items.php b/include/items.php index 9e448e39a..b80c5672b 100644 --- a/include/items.php +++ b/include/items.php @@ -4802,19 +4802,19 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C return $items; } -function webpage_to_namespace($webpage) { +function item_type_to_namespace($item_type) { - if($webpage == ITEM_TYPE_WEBPAGE) + if($item_type == ITEM_TYPE_WEBPAGE) $page_type = 'WEBPAGE'; - elseif($webpage == ITEM_TYPE_BLOCK) + elseif($item_type == ITEM_TYPE_BLOCK) $page_type = 'BUILDBLOCK'; - elseif($webpage == ITEM_TYPE_PDL) + elseif($item_type == ITEM_TYPE_PDL) $page_type = 'PDL'; - elseif($webpage == ITEM_TYPE_CARD) + elseif($item_type == ITEM_TYPE_CARD) $page_type = 'CARD'; - elseif($webpage == ITEM_TYPE_ARTICLE) + elseif($item_type == ITEM_TYPE_ARTICLE) $page_type = 'ARTICLE'; - elseif($webpage == ITEM_TYPE_DOC) + elseif($item_type == ITEM_TYPE_DOC) $page_type = 'docfile'; else $page_type = 'unknown'; @@ -4823,12 +4823,12 @@ function webpage_to_namespace($webpage) { } -function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid) { +function update_remote_id($channel,$post_id,$item_type,$pagetitle,$namespace,$remote_id,$mid) { if(! intval($post_id)) return; - $page_type = webpage_to_namespace($webpage); + $page_type = item_type_to_namespace($item_type); if($page_type == 'unknown' && $namespace && $remote_id) { $page_type = $namespace; @@ -5761,8 +5761,13 @@ function get_recursive_thr_parents(array $item): array|null dbesc($mid) ); + if (!$x) { + break; + } + $mid = $x[0]['thr_parent']; $thr_parents[] = $x[0]['thr_parent']; + $i++; } diff --git a/include/network.php b/include/network.php index cb5027922..83bb281a4 100644 --- a/include/network.php +++ b/include/network.php @@ -433,7 +433,6 @@ function as_return_and_die($obj, $channel = []) { $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ; $headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'); $headers['Digest'] = HTTPSig::generate_digest_header($ret); - $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; if ($channel) { $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel)); diff --git a/tests/unit/includes/AccountTest.php b/tests/unit/includes/AccountTest.php index 3978f9d04..66c761ef5 100644 --- a/tests/unit/includes/AccountTest.php +++ b/tests/unit/includes/AccountTest.php @@ -1,9 +1,28 @@ <?php + +use Zotlabs\Tests\Unit\UnitTestCase; + /** * Tests for account handling helper functions. */ +class AccountTest extends UnitTestCase { + + /** + * Test the `get_account_id()` function. + */ + public function test_get_account_id() { + App::set_account(null); + unset($_SESSION['account_id']); + + $this->assertEquals(false, get_account_id(), 'get_account_id() should return false if not authenticated'); + + App::set_account(['account_id' => 36]); + $this->assertEquals(36, get_account_id(), 'get_account_id() should return account from global App object'); + + $_SESSION['account_id'] = 42; + $this->assertEquals(42, get_account_id(), 'get_account_id() should return the account from the session'); + } -class AccountTest extends Zotlabs\Tests\Unit\UnitTestCase { public function test_get_account_by_id_returns_existing_account() { $account = get_account_by_id(42); $this->assertNotFalse($account); diff --git a/tests/unit/includes/BBCodeTest.php b/tests/unit/includes/BBCodeTest.php index 50475efea..982ef4eb9 100644 --- a/tests/unit/includes/BBCodeTest.php +++ b/tests/unit/includes/BBCodeTest.php @@ -142,20 +142,36 @@ class BBCodeTest extends UnitTestCase { ], 'naked url is converted to link' => [ 'example url: https://example.com', - 'example url: <a href="https://example.com" target="_blank" rel="nofollow noopener">https://example.com</a>' + 'example url: <a href="https://example.com" target="_blank" rel="nofollow noopener">https://example.com</a>' ], 'naked url followed by newline' => [ "https://www.example.com\nhave a great day.", - '<a href="https://www.example.com" target="_blank" rel="nofollow noopener">https://www.example.com</a><br />have a great day.', + '<a href="https://www.example.com" target="_blank" rel="nofollow noopener">https://www.example.com</a><br />have a great day.', ], 'inline naked url' => [ "This is a link https://example.com/some/path more info.", - 'This is a link <a href="https://example.com/some/path" target="_blank" rel="nofollow noopener">https://example.com/some/path</a> more info.', + 'This is a link <a href="https://example.com/some/path" target="_blank" rel="nofollow noopener">https://example.com/some/path</a> more info.', ], 'naked url within code block is not converted to link' => [ "[code]\nhttp://example.com\n[/code]", "<pre><code>http://example.com</code></pre>" ], + 'geo uri is converted to link' => [ + 'example url: [url]geo:37.786971,-122.399677;u=35[/url]', + 'example url: <a href="geo:37.786971,-122.399677;u=35" target="_blank" rel="nofollow noopener">geo:37.786971,-122.399677;u=35</a>' + ], + 'geo uri with label is converted to link' => [ + 'example url: [url=geo:37.786971,-122.399677;u=35(Wikimedia+Foundation)]Wikimedia Foundation[/url]', + 'example url: <a href="geo:37.786971,-122.399677;u=35(Wikimedia+Foundation)" target="_blank" rel="nofollow noopener">Wikimedia Foundation</a>' + ], + 'naked geo uri is converted to link' => [ + 'example url: geo:37.786971,-122.399677;u=35', + 'example url: <a href="geo:37.786971,-122.399677;u=35" target="_blank" rel="nofollow noopener">geo:37.786971,-122.399677;u=35</a>' + ], + 'naked geo uri with label is converted to link' => [ + 'example url: geo:37.78918,-122.40335(Wikimedia+Foundation)', + 'example url: <a href="geo:37.78918,-122.40335(Wikimedia+Foundation)" target="_blank" rel="nofollow noopener">📍Wikimedia Foundation</a>' + ], ]; } @@ -206,7 +222,7 @@ class BBCodeTest extends UnitTestCase { '[rpost=a title]This is the body[/rpost]', true, 'en', - '<a href="https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body" target="_blank" rel="nofollow noopener">https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body</a>', + '<a href="https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body" target="_blank" rel="nofollow noopener">https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body</a>', ], 'unauthenticated observer rpost' => [ '[rpost=a title]This is the body[/rpost]', diff --git a/util/hmessages.po b/util/hmessages.po index 8ef51a278..df91a5b63 100644 --- a/util/hmessages.po +++ b/util/hmessages.po @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: 10.2RC\n" +"Project-Id-Version: 10.4RC1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-05 10:11+0000\n" +"POT-Creation-Date: 2025-06-24 07:52+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -21,7 +21,7 @@ msgstr "" msgid "Source channel not found." msgstr "" -#: ../../view/theme/redbasic/php/config.php:18 ../../include/text.php:3518 +#: ../../view/theme/redbasic/php/config.php:19 ../../include/text.php:3544 #: ../../addon/cart/submodules/orderoptions.php:335 #: ../../addon/cart/submodules/orderoptions.php:359 #: ../../addon/cart/submodules/orderoptions.php:435 @@ -30,13 +30,14 @@ msgstr "" msgid "Default" msgstr "" -#: ../../view/theme/redbasic/php/config.php:19 -#: ../../view/theme/redbasic/php/config.php:22 +#: ../../view/theme/redbasic/php/config.php:20 +#: ../../view/theme/redbasic/php/config.php:23 msgid "Focus (Hubzilla default)" msgstr "" -#: ../../view/theme/redbasic/php/config.php:188 ../../include/js_strings.php:23 -#: ../../addon/irc/irc.php:45 ../../addon/socialauth/Mod_SocialAuth.php:341 +#: ../../view/theme/redbasic/php/config.php:193 ../../include/js_strings.php:21 +#: ../../include/conversation.php:1127 ../../addon/irc/irc.php:45 +#: ../../addon/socialauth/Mod_SocialAuth.php:341 #: ../../addon/hubwall/hubwall.php:96 #: ../../addon/openclipatar/openclipatar.php:54 #: ../../addon/hzfiles/hzfiles.php:86 ../../addon/piwik/piwik.php:95 @@ -45,7 +46,6 @@ msgstr "" #: ../../addon/ijpost/Mod_Ijpost.php:72 ../../addon/redred/Mod_Redred.php:88 #: ../../addon/startpage/Mod_Startpage.php:75 #: ../../addon/libertree/Mod_Libertree.php:68 ../../addon/logrot/logrot.php:35 -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:61 #: ../../addon/dwpost/Mod_Dwpost.php:78 ../../addon/diaspora/diaspora.php:90 #: ../../addon/diaspora/Mod_Diaspora.php:101 #: ../../addon/fuzzloc/Mod_Fuzzloc.php:54 ../../addon/mailtest/mailtest.php:100 @@ -56,7 +56,6 @@ msgstr "" #: ../../addon/statusnet/Mod_Statusnet.php:191 #: ../../addon/statusnet/Mod_Statusnet.php:249 #: ../../addon/statusnet/Mod_Statusnet.php:304 -#: ../../addon/flashcards/Mod_Flashcards.php:269 #: ../../addon/ljpost/Mod_Ljpost.php:80 ../../addon/faces/Mod_Faces.php:141 #: ../../addon/cart/submodules/hzservices.php:645 #: ../../addon/cart/submodules/subscriptions.php:410 @@ -78,7 +77,7 @@ msgstr "" #: ../../addon/rtof/Mod_Rtof.php:70 ../../addon/nofed/Mod_Nofed.php:51 #: ../../addon/photocache/Mod_Photocache.php:63 #: ../../addon/likebanner/likebanner.php:57 -#: ../../Zotlabs/Lib/ThreadItem.php:799 ../../Zotlabs/Storage/Browser.php:386 +#: ../../Zotlabs/Lib/ThreadItem.php:809 ../../Zotlabs/Storage/Browser.php:390 #: ../../Zotlabs/Module/Oauth.php:110 ../../Zotlabs/Module/Import_items.php:125 #: ../../Zotlabs/Module/Thing.php:364 ../../Zotlabs/Module/Thing.php:414 #: ../../Zotlabs/Module/Tokens.php:294 ../../Zotlabs/Module/Pdledit.php:137 @@ -101,15 +100,15 @@ msgstr "" #: ../../Zotlabs/Module/Admin/Security.php:130 #: ../../Zotlabs/Module/Affinity.php:84 ../../Zotlabs/Module/Permcats.php:257 #: ../../Zotlabs/Module/Xchan.php:15 ../../Zotlabs/Module/Group.php:151 -#: ../../Zotlabs/Module/Group.php:160 ../../Zotlabs/Module/Invite.php:564 -#: ../../Zotlabs/Module/Mitem.php:257 ../../Zotlabs/Module/Photos.php:1056 -#: ../../Zotlabs/Module/Photos.php:1095 ../../Zotlabs/Module/Photos.php:1208 +#: ../../Zotlabs/Module/Group.php:160 ../../Zotlabs/Module/Invite.php:547 +#: ../../Zotlabs/Module/Mitem.php:257 ../../Zotlabs/Module/Photos.php:1057 +#: ../../Zotlabs/Module/Photos.php:1096 ../../Zotlabs/Module/Photos.php:1197 #: ../../Zotlabs/Module/Sources.php:123 ../../Zotlabs/Module/Sources.php:160 #: ../../Zotlabs/Module/Profiles.php:738 ../../Zotlabs/Module/Chat.php:208 #: ../../Zotlabs/Module/Chat.php:247 ../../Zotlabs/Module/Regate.php:408 #: ../../Zotlabs/Module/Setup.php:322 ../../Zotlabs/Module/Setup.php:362 #: ../../Zotlabs/Module/Editpost.php:88 ../../Zotlabs/Module/Oauth2.php:115 -#: ../../Zotlabs/Module/Settings/Display.php:188 +#: ../../Zotlabs/Module/Settings/Display.php:187 #: ../../Zotlabs/Module/Settings/Network.php:62 #: ../../Zotlabs/Module/Settings/Channel_home.php:91 #: ../../Zotlabs/Module/Settings/Account.php:109 @@ -131,63 +130,62 @@ msgstr "" msgid "Submit" msgstr "" -#: ../../view/theme/redbasic/php/config.php:192 +#: ../../view/theme/redbasic/php/config.php:197 msgid "Theme settings" msgstr "" -#: ../../view/theme/redbasic/php/config.php:193 +#: ../../view/theme/redbasic/php/config.php:198 msgid "Dark style" msgstr "" -#: ../../view/theme/redbasic/php/config.php:194 +#: ../../view/theme/redbasic/php/config.php:199 msgid "Light style" msgstr "" -#: ../../view/theme/redbasic/php/config.php:195 +#: ../../view/theme/redbasic/php/config.php:200 msgid "Common settings" msgstr "" -#: ../../view/theme/redbasic/php/config.php:196 +#: ../../view/theme/redbasic/php/config.php:201 msgid "Primary theme color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:196 -#: ../../view/theme/redbasic/php/config.php:197 -#: ../../view/theme/redbasic/php/config.php:198 -#: ../../view/theme/redbasic/php/config.php:199 -#: ../../view/theme/redbasic/php/config.php:200 +#: ../../view/theme/redbasic/php/config.php:201 +#: ../../view/theme/redbasic/php/config.php:202 +#: ../../view/theme/redbasic/php/config.php:203 +#: ../../view/theme/redbasic/php/config.php:204 +#: ../../view/theme/redbasic/php/config.php:205 msgid "Current color, leave empty for default" msgstr "" -#: ../../view/theme/redbasic/php/config.php:197 +#: ../../view/theme/redbasic/php/config.php:202 msgid "Success theme color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:198 +#: ../../view/theme/redbasic/php/config.php:203 msgid "Info theme color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:199 +#: ../../view/theme/redbasic/php/config.php:204 msgid "Warning theme color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:200 +#: ../../view/theme/redbasic/php/config.php:205 msgid "Danger theme color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:201 +#: ../../view/theme/redbasic/php/config.php:206 msgid "Default to dark mode" msgstr "" -#: ../../view/theme/redbasic/php/config.php:201 -#: ../../view/theme/redbasic/php/config.php:202 -#: ../../view/theme/redbasic/php/config.php:203 -#: ../../view/theme/redbasic/php/config.php:215 -#: ../../include/conversation.php:1274 +#: ../../view/theme/redbasic/php/config.php:206 +#: ../../view/theme/redbasic/php/config.php:207 +#: ../../view/theme/redbasic/php/config.php:208 +#: ../../view/theme/redbasic/php/config.php:220 +#: ../../include/conversation.php:1159 #: ../../addon/socialauth/Mod_SocialAuth.php:218 #: ../../addon/ijpost/Mod_Ijpost.php:61 ../../addon/redred/Mod_Redred.php:61 #: ../../addon/libertree/Mod_Libertree.php:57 -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:45 #: ../../addon/dwpost/Mod_Dwpost.php:59 ../../addon/dwpost/Mod_Dwpost.php:63 #: ../../addon/diaspora/Mod_Diaspora.php:70 #: ../../addon/pumpio/Mod_Pumpio.php:92 ../../addon/pumpio/Mod_Pumpio.php:96 @@ -223,11 +221,11 @@ msgstr "" #: ../../addon/content_import/Mod_content_import.php:135 #: ../../addon/content_import/Mod_content_import.php:136 #: ../../addon/rtof/Mod_Rtof.php:47 ../../addon/nofed/Mod_Nofed.php:40 -#: ../../boot.php:1759 ../../Zotlabs/Lib/Libzotdir.php:166 +#: ../../boot.php:1766 ../../Zotlabs/Lib/Libzotdir.php:166 #: ../../Zotlabs/Lib/Libzotdir.php:167 ../../Zotlabs/Lib/Libzotdir.php:169 -#: ../../Zotlabs/Storage/Browser.php:310 ../../Zotlabs/Storage/Browser.php:311 -#: ../../Zotlabs/Storage/Browser.php:312 ../../Zotlabs/Storage/Browser.php:393 -#: ../../Zotlabs/Storage/Browser.php:395 ../../Zotlabs/Storage/Browser.php:558 +#: ../../Zotlabs/Storage/Browser.php:314 ../../Zotlabs/Storage/Browser.php:315 +#: ../../Zotlabs/Storage/Browser.php:316 ../../Zotlabs/Storage/Browser.php:397 +#: ../../Zotlabs/Storage/Browser.php:399 ../../Zotlabs/Storage/Browser.php:562 #: ../../Zotlabs/Module/Filestorage.php:203 #: ../../Zotlabs/Module/Filestorage.php:211 #: ../../Zotlabs/Module/Contactedit.php:270 @@ -241,7 +239,7 @@ msgstr "" #: ../../Zotlabs/Module/Group.php:250 ../../Zotlabs/Module/Group.php:302 #: ../../Zotlabs/Module/Group.php:303 ../../Zotlabs/Module/Mitem.php:176 #: ../../Zotlabs/Module/Mitem.php:177 ../../Zotlabs/Module/Mitem.php:254 -#: ../../Zotlabs/Module/Mitem.php:255 ../../Zotlabs/Module/Photos.php:666 +#: ../../Zotlabs/Module/Mitem.php:255 ../../Zotlabs/Module/Photos.php:668 #: ../../Zotlabs/Module/Sources.php:122 ../../Zotlabs/Module/Sources.php:157 #: ../../Zotlabs/Module/Profiles.php:674 ../../Zotlabs/Module/Profiles.php:684 #: ../../Zotlabs/Module/Profiles.php:692 ../../Zotlabs/Module/Profiles.php:696 @@ -259,15 +257,14 @@ msgstr "" msgid "No" msgstr "" -#: ../../view/theme/redbasic/php/config.php:201 -#: ../../view/theme/redbasic/php/config.php:202 -#: ../../view/theme/redbasic/php/config.php:203 -#: ../../view/theme/redbasic/php/config.php:215 -#: ../../include/conversation.php:1274 +#: ../../view/theme/redbasic/php/config.php:206 +#: ../../view/theme/redbasic/php/config.php:207 +#: ../../view/theme/redbasic/php/config.php:208 +#: ../../view/theme/redbasic/php/config.php:220 +#: ../../include/conversation.php:1159 #: ../../addon/socialauth/Mod_SocialAuth.php:218 #: ../../addon/ijpost/Mod_Ijpost.php:61 ../../addon/redred/Mod_Redred.php:61 #: ../../addon/libertree/Mod_Libertree.php:57 -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:45 #: ../../addon/dwpost/Mod_Dwpost.php:59 ../../addon/dwpost/Mod_Dwpost.php:63 #: ../../addon/diaspora/Mod_Diaspora.php:70 #: ../../addon/pumpio/Mod_Pumpio.php:92 ../../addon/pumpio/Mod_Pumpio.php:96 @@ -303,11 +300,11 @@ msgstr "" #: ../../addon/content_import/Mod_content_import.php:135 #: ../../addon/content_import/Mod_content_import.php:136 #: ../../addon/rtof/Mod_Rtof.php:47 ../../addon/nofed/Mod_Nofed.php:40 -#: ../../boot.php:1759 ../../Zotlabs/Lib/Libzotdir.php:166 +#: ../../boot.php:1766 ../../Zotlabs/Lib/Libzotdir.php:166 #: ../../Zotlabs/Lib/Libzotdir.php:167 ../../Zotlabs/Lib/Libzotdir.php:169 -#: ../../Zotlabs/Storage/Browser.php:310 ../../Zotlabs/Storage/Browser.php:311 -#: ../../Zotlabs/Storage/Browser.php:312 ../../Zotlabs/Storage/Browser.php:393 -#: ../../Zotlabs/Storage/Browser.php:395 ../../Zotlabs/Storage/Browser.php:558 +#: ../../Zotlabs/Storage/Browser.php:314 ../../Zotlabs/Storage/Browser.php:315 +#: ../../Zotlabs/Storage/Browser.php:316 ../../Zotlabs/Storage/Browser.php:397 +#: ../../Zotlabs/Storage/Browser.php:399 ../../Zotlabs/Storage/Browser.php:562 #: ../../Zotlabs/Module/Filestorage.php:203 #: ../../Zotlabs/Module/Filestorage.php:211 #: ../../Zotlabs/Module/Contactedit.php:270 @@ -319,7 +316,7 @@ msgstr "" #: ../../Zotlabs/Module/Group.php:250 ../../Zotlabs/Module/Group.php:302 #: ../../Zotlabs/Module/Group.php:303 ../../Zotlabs/Module/Mitem.php:176 #: ../../Zotlabs/Module/Mitem.php:177 ../../Zotlabs/Module/Mitem.php:254 -#: ../../Zotlabs/Module/Mitem.php:255 ../../Zotlabs/Module/Photos.php:666 +#: ../../Zotlabs/Module/Mitem.php:255 ../../Zotlabs/Module/Photos.php:668 #: ../../Zotlabs/Module/Sources.php:122 ../../Zotlabs/Module/Sources.php:157 #: ../../Zotlabs/Module/Profiles.php:674 ../../Zotlabs/Module/Profiles.php:684 #: ../../Zotlabs/Module/Profiles.php:692 ../../Zotlabs/Module/Profiles.php:696 @@ -337,80 +334,80 @@ msgstr "" msgid "Yes" msgstr "" -#: ../../view/theme/redbasic/php/config.php:202 +#: ../../view/theme/redbasic/php/config.php:207 msgid "Always use light icons for navbar" msgstr "" -#: ../../view/theme/redbasic/php/config.php:202 +#: ../../view/theme/redbasic/php/config.php:207 msgid "Enable this option if you use a dark navbar color in light mode" msgstr "" -#: ../../view/theme/redbasic/php/config.php:203 +#: ../../view/theme/redbasic/php/config.php:208 msgid "Narrow navbar" msgstr "" -#: ../../view/theme/redbasic/php/config.php:204 +#: ../../view/theme/redbasic/php/config.php:209 msgid "Navigation bar background color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:205 +#: ../../view/theme/redbasic/php/config.php:210 msgid "Dark navigation bar background color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:206 +#: ../../view/theme/redbasic/php/config.php:211 msgid "Set the background color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:207 +#: ../../view/theme/redbasic/php/config.php:212 msgid "Set the dark background color" msgstr "" -#: ../../view/theme/redbasic/php/config.php:208 +#: ../../view/theme/redbasic/php/config.php:213 msgid "Set the background image" msgstr "" -#: ../../view/theme/redbasic/php/config.php:209 +#: ../../view/theme/redbasic/php/config.php:214 msgid "Set the dark background image" msgstr "" -#: ../../view/theme/redbasic/php/config.php:210 +#: ../../view/theme/redbasic/php/config.php:215 msgid "Set font-size for the entire application" msgstr "" -#: ../../view/theme/redbasic/php/config.php:210 +#: ../../view/theme/redbasic/php/config.php:215 msgid "Examples: 1rem, 100%, 16px" msgstr "" -#: ../../view/theme/redbasic/php/config.php:211 +#: ../../view/theme/redbasic/php/config.php:216 msgid "Set radius of corners in rem" msgstr "" -#: ../../view/theme/redbasic/php/config.php:211 +#: ../../view/theme/redbasic/php/config.php:216 msgid "Leave empty for default radius" msgstr "" -#: ../../view/theme/redbasic/php/config.php:212 +#: ../../view/theme/redbasic/php/config.php:217 msgid "Set maximum width of content region in rem" msgstr "" -#: ../../view/theme/redbasic/php/config.php:212 +#: ../../view/theme/redbasic/php/config.php:217 msgid "Leave empty for default width" msgstr "" -#: ../../view/theme/redbasic/php/config.php:213 +#: ../../view/theme/redbasic/php/config.php:218 msgid "Set size of conversation author photo" msgstr "" -#: ../../view/theme/redbasic/php/config.php:213 -#: ../../view/theme/redbasic/php/config.php:214 +#: ../../view/theme/redbasic/php/config.php:218 +#: ../../view/theme/redbasic/php/config.php:219 msgid "Leave empty for default size" msgstr "" -#: ../../view/theme/redbasic/php/config.php:214 +#: ../../view/theme/redbasic/php/config.php:219 msgid "Set size of followup author photos" msgstr "" -#: ../../view/theme/redbasic/php/config.php:215 +#: ../../view/theme/redbasic/php/config.php:220 msgid "Show advanced settings" msgstr "" @@ -424,23 +421,23 @@ msgstr "" msgid "This is the home page of %s." msgstr "" -#: ../../include/auth.php:232 +#: ../../include/auth.php:231 msgid "Delegation session ended." msgstr "" -#: ../../include/auth.php:236 +#: ../../include/auth.php:235 msgid "Logged out." msgstr "" -#: ../../include/auth.php:342 +#: ../../include/auth.php:341 msgid "Email validation is incomplete. Please check your email." msgstr "" -#: ../../include/auth.php:358 +#: ../../include/auth.php:357 msgid "Failed authentication" msgstr "" -#: ../../include/auth.php:368 ../../addon/openid/Mod_Openid.php:189 +#: ../../include/auth.php:367 ../../addon/openid/Mod_Openid.php:189 msgid "Login failed." msgstr "" @@ -502,8 +499,8 @@ msgid "This event has been added to your calendar." msgstr "" #: ../../include/event.php:1366 ../../include/conversation.php:153 -#: ../../include/text.php:2359 ../../Zotlabs/Module/Tagger.php:77 -#: ../../Zotlabs/Module/Like.php:453 +#: ../../include/text.php:2380 ../../Zotlabs/Module/Tagger.php:77 +#: ../../Zotlabs/Module/Like.php:441 #: ../../Zotlabs/Module/Channel_calendar.php:209 msgid "event" msgstr "" @@ -534,7 +531,6 @@ msgid "Mobile" msgstr "" #: ../../include/event.php:1536 ../../include/connections.php:791 -#: ../../Zotlabs/Widget/Notifications.php:43 #: ../../Zotlabs/Module/Connedit.php:742 ../../Zotlabs/Module/Cdav.php:1378 msgid "Home" msgstr "" @@ -569,80 +565,79 @@ msgstr "" msgid "Other" msgstr "" -#: ../../include/feedutils.php:863 ../../include/text.php:1580 +#: ../../include/feedutils.php:863 ../../include/text.php:1602 msgid "unknown" msgstr "" -#: ../../include/items.php:481 ../../addon/hzfiles/hzfiles.php:75 +#: ../../include/items.php:484 ../../addon/hzfiles/hzfiles.php:75 #: ../../addon/redphotos/redphotos.php:119 #: ../../addon/redfiles/redfiles.php:109 #: ../../Zotlabs/Module/Import_items.php:116 #: ../../Zotlabs/Module/Dreport.php:10 ../../Zotlabs/Module/Dreport.php:60 #: ../../Zotlabs/Module/Subthread.php:89 ../../Zotlabs/Module/Group.php:109 -#: ../../Zotlabs/Module/Like.php:344 ../../Zotlabs/Module/Profperm.php:29 -#: ../../Zotlabs/Web/WebServer.php:120 +#: ../../Zotlabs/Module/Like.php:332 ../../Zotlabs/Module/Profperm.php:29 msgid "Permission denied" msgstr "" -#: ../../include/items.php:1275 +#: ../../include/items.php:1278 msgid "Visible to anybody on the internet." msgstr "" -#: ../../include/items.php:1277 +#: ../../include/items.php:1280 msgid "Visible to you only." msgstr "" -#: ../../include/items.php:1279 +#: ../../include/items.php:1282 msgid "Visible to anybody in this network." msgstr "" -#: ../../include/items.php:1281 +#: ../../include/items.php:1284 msgid "Visible to anybody authenticated." msgstr "" -#: ../../include/items.php:1283 +#: ../../include/items.php:1286 #, php-format msgid "Visible to anybody on %s." msgstr "" -#: ../../include/items.php:1285 +#: ../../include/items.php:1288 msgid "Visible to all connections." msgstr "" -#: ../../include/items.php:1287 +#: ../../include/items.php:1290 msgid "Visible to approved connections." msgstr "" -#: ../../include/items.php:1289 +#: ../../include/items.php:1292 msgid "Visible to specific connections." msgstr "" -#: ../../include/items.php:3491 ../../Zotlabs/Lib/Activity.php:2282 +#: ../../include/items.php:3502 ../../Zotlabs/Lib/Activity.php:2225 #: ../../Zotlabs/Module/Share.php:124 #, php-format msgid "🔁 Repeated %1$s's %2$s" msgstr "" -#: ../../include/items.php:4568 ../../Zotlabs/Module/Group.php:63 +#: ../../include/items.php:4579 ../../Zotlabs/Module/Group.php:63 #: ../../Zotlabs/Module/Group.php:207 msgid "Privacy group not found." msgstr "" -#: ../../include/items.php:4584 +#: ../../include/items.php:4595 msgid "Privacy group is empty." msgstr "" -#: ../../include/items.php:4591 +#: ../../include/items.php:4602 #, php-format msgid "Privacy group: %s" msgstr "" -#: ../../include/items.php:4601 +#: ../../include/items.php:4612 #, php-format msgid "Connection: %s" msgstr "" -#: ../../include/items.php:4603 +#: ../../include/items.php:4614 msgid "Connection not found." msgstr "" @@ -863,7 +858,8 @@ msgstr "" msgid "Change channels directly from within the navigation dropdown menu" msgstr "" -#: ../../include/features.php:296 ../../Zotlabs/Widget/Notifications.php:23 +#: ../../include/features.php:296 ../../Zotlabs/Lib/Apps.php:344 +#: ../../Zotlabs/Widget/Notifications.php:23 #: ../../Zotlabs/Module/Connections.php:347 msgid "Network" msgstr "" @@ -990,12 +986,12 @@ msgstr "" msgid "Ability to create multiple profiles" msgstr "" -#: ../../include/attach.php:156 ../../include/attach.php:205 -#: ../../include/attach.php:278 ../../include/attach.php:329 -#: ../../include/attach.php:431 ../../include/attach.php:445 -#: ../../include/attach.php:452 ../../include/attach.php:534 -#: ../../include/attach.php:1106 ../../include/attach.php:1179 -#: ../../include/attach.php:1344 ../../include/photos.php:32 +#: ../../include/attach.php:157 ../../include/attach.php:206 +#: ../../include/attach.php:279 ../../include/attach.php:330 +#: ../../include/attach.php:432 ../../include/attach.php:446 +#: ../../include/attach.php:453 ../../include/attach.php:535 +#: ../../include/attach.php:1115 ../../include/attach.php:1188 +#: ../../include/attach.php:1359 ../../include/photos.php:32 #: ../../addon/openid/Mod_Id.php:53 ../../addon/keepout/keepout.php:36 #: ../../addon/cards/Mod_Cards.php:89 ../../addon/cards/Mod_Card_edit.php:51 #: ../../addon/pumpio/pumpio.php:44 @@ -1003,7 +999,7 @@ msgstr "" #: ../../addon/articles/Mod_Articles.php:94 ../../addon/wiki/Mod_Wiki.php:63 #: ../../addon/wiki/Mod_Wiki.php:288 ../../addon/wiki/Mod_Wiki.php:425 #: ../../Zotlabs/Lib/Chatroom.php:135 ../../Zotlabs/Module/Page.php:34 -#: ../../Zotlabs/Module/Page.php:133 ../../Zotlabs/Module/Display.php:392 +#: ../../Zotlabs/Module/Page.php:133 ../../Zotlabs/Module/Display.php:387 #: ../../Zotlabs/Module/Cover_photo.php:299 #: ../../Zotlabs/Module/Cover_photo.php:312 #: ../../Zotlabs/Module/Editwebpage.php:68 @@ -1020,9 +1016,9 @@ msgstr "" #: ../../Zotlabs/Module/Filestorage.php:119 #: ../../Zotlabs/Module/Filestorage.php:165 #: ../../Zotlabs/Module/Register.php:201 ../../Zotlabs/Module/Appman.php:163 -#: ../../Zotlabs/Module/Viewsrc.php:19 ../../Zotlabs/Module/Item.php:288 -#: ../../Zotlabs/Module/Item.php:307 ../../Zotlabs/Module/Item.php:317 -#: ../../Zotlabs/Module/Item.php:1276 ../../Zotlabs/Module/Achievements.php:34 +#: ../../Zotlabs/Module/Viewsrc.php:19 ../../Zotlabs/Module/Item.php:289 +#: ../../Zotlabs/Module/Item.php:308 ../../Zotlabs/Module/Item.php:318 +#: ../../Zotlabs/Module/Item.php:1272 ../../Zotlabs/Module/Achievements.php:34 #: ../../Zotlabs/Module/Connedit.php:299 ../../Zotlabs/Module/Defperms.php:181 #: ../../Zotlabs/Module/Suggest.php:32 ../../Zotlabs/Module/Regmod.php:20 #: ../../Zotlabs/Module/Profile_photo.php:390 @@ -1039,12 +1035,12 @@ msgstr "" #: ../../Zotlabs/Module/Attach_edit.php:99 #: ../../Zotlabs/Module/Attach_edit.php:106 ../../Zotlabs/Module/Group.php:15 #: ../../Zotlabs/Module/Group.php:31 ../../Zotlabs/Module/Invite.php:65 -#: ../../Zotlabs/Module/Invite.php:316 ../../Zotlabs/Module/Like.php:242 +#: ../../Zotlabs/Module/Invite.php:316 ../../Zotlabs/Module/Like.php:230 #: ../../Zotlabs/Module/Blocks.php:73 ../../Zotlabs/Module/Blocks.php:80 #: ../../Zotlabs/Module/Mitem.php:129 ../../Zotlabs/Module/New_channel.php:106 #: ../../Zotlabs/Module/New_channel.php:131 ../../Zotlabs/Module/Photos.php:71 -#: ../../Zotlabs/Module/Channel.php:234 ../../Zotlabs/Module/Channel.php:391 -#: ../../Zotlabs/Module/Channel.php:429 ../../Zotlabs/Module/Profile.php:99 +#: ../../Zotlabs/Module/Channel.php:234 ../../Zotlabs/Module/Channel.php:395 +#: ../../Zotlabs/Module/Channel.php:434 ../../Zotlabs/Module/Profile.php:99 #: ../../Zotlabs/Module/Profile.php:114 ../../Zotlabs/Module/Moderate.php:15 #: ../../Zotlabs/Module/Sources.php:80 ../../Zotlabs/Module/Profiles.php:168 #: ../../Zotlabs/Module/Profiles.php:611 @@ -1057,92 +1053,99 @@ msgstr "" #: ../../Zotlabs/Module/Setup.php:220 ../../Zotlabs/Module/Editpost.php:17 #: ../../Zotlabs/Module/Connections.php:32 #: ../../Zotlabs/Module/Editblock.php:67 ../../Zotlabs/Module/Vote.php:19 -#: ../../Zotlabs/Web/WebServer.php:121 msgid "Permission denied." msgstr "" -#: ../../include/attach.php:273 ../../include/attach.php:324 -#: ../../include/attach.php:426 +#: ../../include/attach.php:274 ../../include/attach.php:325 +#: ../../include/attach.php:427 msgid "Item was not found." msgstr "" -#: ../../include/attach.php:290 +#: ../../include/attach.php:291 msgid "Unknown error." msgstr "" -#: ../../include/attach.php:621 +#: ../../include/attach.php:622 msgid "No source file." msgstr "" -#: ../../include/attach.php:643 +#: ../../include/attach.php:644 msgid "Cannot locate file to replace" msgstr "" -#: ../../include/attach.php:662 +#: ../../include/attach.php:663 msgid "Cannot locate file to revise/update" msgstr "" -#: ../../include/attach.php:808 +#: ../../include/attach.php:804 ../../include/attach.php:2609 +msgid "Filename too long" +msgstr "" + +#: ../../include/attach.php:817 #, php-format msgid "File exceeds size limit of %d" msgstr "" -#: ../../include/attach.php:829 +#: ../../include/attach.php:838 #, php-format msgid "You have reached your limit of %1$.0f Mbytes attachment storage." msgstr "" -#: ../../include/attach.php:1019 +#: ../../include/attach.php:1028 msgid "File upload failed. Possible system limit or action terminated." msgstr "" -#: ../../include/attach.php:1048 +#: ../../include/attach.php:1057 msgid "Stored file could not be verified. Upload failed." msgstr "" -#: ../../include/attach.php:1120 ../../include/attach.php:1136 +#: ../../include/attach.php:1129 ../../include/attach.php:1145 msgid "Path not available." msgstr "" -#: ../../include/attach.php:1184 ../../include/attach.php:1349 +#: ../../include/attach.php:1193 ../../include/attach.php:1364 msgid "Empty pathname" msgstr "" -#: ../../include/attach.php:1210 +#: ../../include/attach.php:1199 +msgid "Pathname too long" +msgstr "" + +#: ../../include/attach.php:1225 msgid "duplicate filename or path" msgstr "" -#: ../../include/attach.php:1238 +#: ../../include/attach.php:1253 msgid "Path not found." msgstr "" -#: ../../include/attach.php:1305 +#: ../../include/attach.php:1320 msgid "mkdir failed." msgstr "" -#: ../../include/attach.php:1309 +#: ../../include/attach.php:1324 msgid "database storage failed." msgstr "" -#: ../../include/attach.php:1355 +#: ../../include/attach.php:1370 msgid "Empty path" msgstr "" -#: ../../include/attach.php:1992 +#: ../../include/attach.php:2007 #, php-format msgid "%s shared an %s with you" msgstr "" -#: ../../include/attach.php:1992 +#: ../../include/attach.php:2007 #, php-format msgid "%s shared a %s with you" msgstr "" -#: ../../include/attach.php:1992 ../../Zotlabs/Module/Like.php:450 +#: ../../include/attach.php:2007 ../../Zotlabs/Module/Like.php:438 msgid "image" msgstr "" -#: ../../include/attach.php:1992 ../../addon/redfiles/redfilehelper.php:64 +#: ../../include/attach.php:2007 ../../addon/redfiles/redfilehelper.php:64 msgid "file" msgstr "" @@ -1505,8 +1508,8 @@ msgstr "" #: ../../include/taxonomy.php:527 ../../include/taxonomy.php:548 #: ../../addon/cards/Widget/Cards_categories.php:80 #: ../../addon/articles/Widget/Articles_categories.php:80 -#: ../../Zotlabs/Storage/Browser.php:293 ../../Zotlabs/Storage/Browser.php:392 -#: ../../Zotlabs/Storage/Browser.php:406 ../../Zotlabs/Module/Cdav.php:1062 +#: ../../Zotlabs/Storage/Browser.php:297 ../../Zotlabs/Storage/Browser.php:396 +#: ../../Zotlabs/Storage/Browser.php:410 ../../Zotlabs/Module/Cdav.php:1062 msgid "Categories" msgstr "" @@ -1528,12 +1531,11 @@ msgid "Summary: " msgstr "" #: ../../include/cdav.php:158 ../../include/cdav.php:159 -#: ../../include/cdav.php:167 ../../include/conversation.php:1006 -#: ../../Zotlabs/Lib/Apps.php:1168 ../../Zotlabs/Lib/Apps.php:1252 -#: ../../Zotlabs/Lib/Activity.php:1726 ../../Zotlabs/Widget/Album.php:90 -#: ../../Zotlabs/Widget/Pinned.php:256 ../../Zotlabs/Widget/Portfolio.php:99 -#: ../../Zotlabs/Module/Embedphotos.php:177 ../../Zotlabs/Module/Photos.php:788 -#: ../../Zotlabs/Module/Photos.php:1246 +#: ../../include/cdav.php:167 ../../Zotlabs/Lib/Apps.php:1168 +#: ../../Zotlabs/Lib/Apps.php:1252 ../../Zotlabs/Lib/Activity.php:1696 +#: ../../Zotlabs/Widget/Album.php:93 ../../Zotlabs/Widget/Portfolio.php:103 +#: ../../Zotlabs/Module/Embedphotos.php:179 ../../Zotlabs/Module/Photos.php:790 +#: ../../Zotlabs/Module/Photos.php:1240 msgid "Unknown" msgstr "" @@ -1619,7 +1621,7 @@ msgstr "" msgid "wants" msgstr "" -#: ../../include/taxonomy.php:589 ../../Zotlabs/Lib/ThreadItem.php:296 +#: ../../include/taxonomy.php:589 msgid "like" msgstr "" @@ -1627,7 +1629,7 @@ msgstr "" msgid "likes" msgstr "" -#: ../../include/taxonomy.php:590 ../../Zotlabs/Lib/ThreadItem.php:297 +#: ../../include/taxonomy.php:590 msgid "dislike" msgstr "" @@ -1635,15 +1637,15 @@ msgstr "" msgid "dislikes" msgstr "" -#: ../../include/taxonomy.php:677 ../../include/conversation.php:1561 -#: ../../Zotlabs/Module/Photos.php:1129 +#: ../../include/taxonomy.php:677 ../../include/conversation.php:1440 +#: ../../Zotlabs/Module/Photos.php:1118 msgctxt "noun" msgid "Like" msgid_plural "Likes" msgstr[0] "" msgstr[1] "" -#: ../../include/photo/photo_driver.php:458 +#: ../../include/photo/photo_driver.php:439 #: ../../Zotlabs/Module/Profile_photo.php:168 #: ../../Zotlabs/Module/Profile_photo.php:337 msgid "Profile Photos" @@ -1675,73 +1677,68 @@ msgstr "" msgid "Invitation could not be verified." msgstr "" -#: ../../include/account.php:192 -msgid "Please enter the required information." -msgstr "" - -#: ../../include/account.php:259 ../../include/account.php:367 +#: ../../include/account.php:206 msgid "Failed to store account information." msgstr "" -#: ../../include/account.php:436 ../../include/account.php:504 -#: ../../Zotlabs/Module/Register.php:329 +#: ../../include/account.php:275 ../../Zotlabs/Module/Register.php:329 #, php-format msgid "Registration confirmation for %s" msgstr "" -#: ../../include/account.php:579 +#: ../../include/account.php:348 #, php-format msgid "Registration request at %s" msgstr "" -#: ../../include/account.php:601 +#: ../../include/account.php:370 msgid "your registration password" msgstr "" -#: ../../include/account.php:607 ../../include/account.php:680 +#: ../../include/account.php:376 ../../include/account.php:449 #, php-format msgid "Registration details for %s" msgstr "" -#: ../../include/account.php:695 +#: ../../include/account.php:464 msgid "Account approved." msgstr "" -#: ../../include/account.php:747 +#: ../../include/account.php:516 #, php-format msgid "Registration revoked for %s" msgstr "" -#: ../../include/account.php:754 +#: ../../include/account.php:523 #, php-format msgid "Could not revoke registration for %s" msgstr "" -#: ../../include/account.php:1171 ../../include/account.php:1173 +#: ../../include/account.php:940 ../../include/account.php:942 msgid "Click here to upgrade." msgstr "" -#: ../../include/account.php:1179 +#: ../../include/account.php:948 msgid "This action exceeds the limits set by your subscription plan." msgstr "" -#: ../../include/account.php:1184 +#: ../../include/account.php:953 msgid "This action is not available under your subscription plan." msgstr "" -#: ../../include/account.php:1244 +#: ../../include/account.php:1013 msgid "open" msgstr "" -#: ../../include/account.php:1244 +#: ../../include/account.php:1013 msgid "closed" msgstr "" -#: ../../include/account.php:1251 +#: ../../include/account.php:1020 msgid "Registration is currently" msgstr "" -#: ../../include/account.php:1260 +#: ../../include/account.php:1029 msgid "please come back" msgstr "" @@ -1753,367 +1750,363 @@ msgstr "" msgid "Item deleted" msgstr "" -#: ../../include/js_strings.php:7 ../../Zotlabs/Lib/ThreadItem.php:798 -#: ../../Zotlabs/Module/Photos.php:1094 ../../Zotlabs/Module/Photos.php:1207 +#: ../../include/js_strings.php:7 ../../Zotlabs/Lib/ThreadItem.php:808 +#: ../../Zotlabs/Module/Photos.php:1095 ../../Zotlabs/Module/Photos.php:1196 msgid "Comment" msgstr "" -#: ../../include/js_strings.php:8 ../../Zotlabs/Lib/ThreadItem.php:507 -msgid "show all" -msgstr "" - -#: ../../include/js_strings.php:9 -msgid "show less" -msgstr "" - -#: ../../include/js_strings.php:10 +#: ../../include/js_strings.php:8 msgid "expand" msgstr "" -#: ../../include/js_strings.php:11 +#: ../../include/js_strings.php:9 msgid "collapse" msgstr "" -#: ../../include/js_strings.php:12 +#: ../../include/js_strings.php:10 msgid "Password too short" msgstr "" -#: ../../include/js_strings.php:13 ../../Zotlabs/Module/Register.php:162 +#: ../../include/js_strings.php:11 ../../Zotlabs/Module/Register.php:162 msgid "Passwords do not match" msgstr "" -#: ../../include/js_strings.php:14 +#: ../../include/js_strings.php:12 msgid "everybody" msgstr "" -#: ../../include/js_strings.php:15 +#: ../../include/js_strings.php:13 msgid "Secret Passphrase" msgstr "" -#: ../../include/js_strings.php:16 +#: ../../include/js_strings.php:14 msgid "Passphrase hint" msgstr "" -#: ../../include/js_strings.php:17 +#: ../../include/js_strings.php:15 msgid "Notice: Permissions have changed but have not yet been submitted." msgstr "" -#: ../../include/js_strings.php:18 +#: ../../include/js_strings.php:16 msgid "close all" msgstr "" -#: ../../include/js_strings.php:19 +#: ../../include/js_strings.php:17 msgid "Nothing new here" msgstr "" -#: ../../include/js_strings.php:20 +#: ../../include/js_strings.php:18 msgid "Rate This Channel (this is public)" msgstr "" -#: ../../include/js_strings.php:21 +#: ../../include/js_strings.php:19 msgid "Rating" msgstr "" -#: ../../include/js_strings.php:22 +#: ../../include/js_strings.php:20 msgid "Describe (optional)" msgstr "" -#: ../../include/js_strings.php:24 +#: ../../include/js_strings.php:22 msgid "Please enter a link URL" msgstr "" -#: ../../include/js_strings.php:25 +#: ../../include/js_strings.php:23 msgid "Unsaved changes. Are you sure you wish to leave this page?" msgstr "" -#: ../../include/js_strings.php:26 ../../Zotlabs/Module/Locs.php:121 +#: ../../include/js_strings.php:24 ../../Zotlabs/Module/Locs.php:121 #: ../../Zotlabs/Module/Pubsites.php:55 ../../Zotlabs/Module/Profiles.php:476 #: ../../Zotlabs/Module/Profiles.php:749 ../../Zotlabs/Module/Cdav.php:1006 msgid "Location" msgstr "" -#: ../../include/js_strings.php:27 +#: ../../include/js_strings.php:25 msgid "lovely" msgstr "" -#: ../../include/js_strings.php:28 +#: ../../include/js_strings.php:26 msgid "wonderful" msgstr "" -#: ../../include/js_strings.php:29 +#: ../../include/js_strings.php:27 msgid "fantastic" msgstr "" -#: ../../include/js_strings.php:30 +#: ../../include/js_strings.php:28 msgid "great" msgstr "" -#: ../../include/js_strings.php:31 +#: ../../include/js_strings.php:29 msgid "" "Your chosen nickname was either already taken or not valid. Please use our " "suggestion (" msgstr "" -#: ../../include/js_strings.php:32 +#: ../../include/js_strings.php:30 msgid ") or enter a new one." msgstr "" -#: ../../include/js_strings.php:33 +#: ../../include/js_strings.php:31 msgid "Thank you, this nickname is valid." msgstr "" -#: ../../include/js_strings.php:34 +#: ../../include/js_strings.php:32 msgid "A channel name is required." msgstr "" -#: ../../include/js_strings.php:35 +#: ../../include/js_strings.php:33 msgid "This is a " msgstr "" -#: ../../include/js_strings.php:36 +#: ../../include/js_strings.php:34 msgid " channel name" msgstr "" -#: ../../include/js_strings.php:37 +#: ../../include/js_strings.php:35 msgid "Back to reply" msgstr "" -#: ../../include/js_strings.php:38 +#: ../../include/js_strings.php:36 msgid "Pinned" msgstr "" -#: ../../include/js_strings.php:39 ../../Zotlabs/Lib/ThreadItem.php:457 +#: ../../include/js_strings.php:37 ../../Zotlabs/Lib/ThreadItem.php:454 msgid "Pin to the top" msgstr "" -#: ../../include/js_strings.php:40 ../../Zotlabs/Lib/ThreadItem.php:457 -#: ../../Zotlabs/Widget/Pinned.php:150 +#: ../../include/js_strings.php:38 ../../Zotlabs/Lib/ThreadItem.php:454 +#: ../../Zotlabs/Widget/Pinned.php:153 msgid "Unpin from the top" msgstr "" -#: ../../include/js_strings.php:46 +#: ../../include/js_strings.php:39 +msgid "Double click to exit zoom" +msgstr "" + +#: ../../include/js_strings.php:45 #, php-format msgid "%d minutes" msgid_plural "%d minutes" msgstr[0] "" msgstr[1] "" -#: ../../include/js_strings.php:47 +#: ../../include/js_strings.php:46 #, php-format msgid "about %d hours" msgid_plural "about %d hours" msgstr[0] "" msgstr[1] "" -#: ../../include/js_strings.php:48 +#: ../../include/js_strings.php:47 #, php-format msgid "%d days" msgid_plural "%d days" msgstr[0] "" msgstr[1] "" -#: ../../include/js_strings.php:49 +#: ../../include/js_strings.php:48 #, php-format msgid "%d months" msgid_plural "%d months" msgstr[0] "" msgstr[1] "" -#: ../../include/js_strings.php:50 +#: ../../include/js_strings.php:49 #, php-format msgid "%d years" msgid_plural "%d years" msgstr[0] "" msgstr[1] "" -#: ../../include/js_strings.php:52 ../../include/text.php:1503 +#: ../../include/js_strings.php:51 ../../include/text.php:1525 msgid "January" msgstr "" -#: ../../include/js_strings.php:53 ../../include/text.php:1503 +#: ../../include/js_strings.php:52 ../../include/text.php:1525 msgid "February" msgstr "" -#: ../../include/js_strings.php:54 ../../include/text.php:1503 +#: ../../include/js_strings.php:53 ../../include/text.php:1525 msgid "March" msgstr "" -#: ../../include/js_strings.php:55 ../../include/text.php:1503 +#: ../../include/js_strings.php:54 ../../include/text.php:1525 msgid "April" msgstr "" -#: ../../include/js_strings.php:56 +#: ../../include/js_strings.php:55 msgctxt "long" msgid "May" msgstr "" -#: ../../include/js_strings.php:57 ../../include/text.php:1503 +#: ../../include/js_strings.php:56 ../../include/text.php:1525 msgid "June" msgstr "" -#: ../../include/js_strings.php:58 ../../include/text.php:1503 +#: ../../include/js_strings.php:57 ../../include/text.php:1525 msgid "July" msgstr "" -#: ../../include/js_strings.php:59 ../../include/text.php:1503 +#: ../../include/js_strings.php:58 ../../include/text.php:1525 msgid "August" msgstr "" -#: ../../include/js_strings.php:60 ../../include/text.php:1503 +#: ../../include/js_strings.php:59 ../../include/text.php:1525 msgid "September" msgstr "" -#: ../../include/js_strings.php:61 ../../include/text.php:1503 +#: ../../include/js_strings.php:60 ../../include/text.php:1525 msgid "October" msgstr "" -#: ../../include/js_strings.php:62 ../../include/text.php:1503 +#: ../../include/js_strings.php:61 ../../include/text.php:1525 msgid "November" msgstr "" -#: ../../include/js_strings.php:63 ../../include/text.php:1503 +#: ../../include/js_strings.php:62 ../../include/text.php:1525 msgid "December" msgstr "" -#: ../../include/js_strings.php:64 +#: ../../include/js_strings.php:63 msgid "Jan" msgstr "" -#: ../../include/js_strings.php:65 +#: ../../include/js_strings.php:64 msgid "Feb" msgstr "" -#: ../../include/js_strings.php:66 +#: ../../include/js_strings.php:65 msgid "Mar" msgstr "" -#: ../../include/js_strings.php:67 +#: ../../include/js_strings.php:66 msgid "Apr" msgstr "" -#: ../../include/js_strings.php:68 +#: ../../include/js_strings.php:67 msgctxt "short" msgid "May" msgstr "" -#: ../../include/js_strings.php:69 +#: ../../include/js_strings.php:68 msgid "Jun" msgstr "" -#: ../../include/js_strings.php:70 +#: ../../include/js_strings.php:69 msgid "Jul" msgstr "" -#: ../../include/js_strings.php:71 +#: ../../include/js_strings.php:70 msgid "Aug" msgstr "" -#: ../../include/js_strings.php:72 +#: ../../include/js_strings.php:71 msgid "Sep" msgstr "" -#: ../../include/js_strings.php:73 +#: ../../include/js_strings.php:72 msgid "Oct" msgstr "" -#: ../../include/js_strings.php:74 +#: ../../include/js_strings.php:73 msgid "Nov" msgstr "" -#: ../../include/js_strings.php:75 +#: ../../include/js_strings.php:74 msgid "Dec" msgstr "" -#: ../../include/js_strings.php:76 ../../include/text.php:1499 +#: ../../include/js_strings.php:75 ../../include/text.php:1521 msgid "Sunday" msgstr "" -#: ../../include/js_strings.php:77 ../../include/text.php:1499 +#: ../../include/js_strings.php:76 ../../include/text.php:1521 msgid "Monday" msgstr "" -#: ../../include/js_strings.php:78 ../../include/text.php:1499 +#: ../../include/js_strings.php:77 ../../include/text.php:1521 msgid "Tuesday" msgstr "" -#: ../../include/js_strings.php:79 ../../include/text.php:1499 +#: ../../include/js_strings.php:78 ../../include/text.php:1521 msgid "Wednesday" msgstr "" -#: ../../include/js_strings.php:80 ../../include/text.php:1499 +#: ../../include/js_strings.php:79 ../../include/text.php:1521 msgid "Thursday" msgstr "" -#: ../../include/js_strings.php:81 ../../include/text.php:1499 +#: ../../include/js_strings.php:80 ../../include/text.php:1521 msgid "Friday" msgstr "" -#: ../../include/js_strings.php:82 ../../include/text.php:1499 +#: ../../include/js_strings.php:81 ../../include/text.php:1521 msgid "Saturday" msgstr "" -#: ../../include/js_strings.php:83 +#: ../../include/js_strings.php:82 msgid "Sun" msgstr "" -#: ../../include/js_strings.php:84 +#: ../../include/js_strings.php:83 msgid "Mon" msgstr "" -#: ../../include/js_strings.php:85 +#: ../../include/js_strings.php:84 msgid "Tue" msgstr "" -#: ../../include/js_strings.php:86 +#: ../../include/js_strings.php:85 msgid "Wed" msgstr "" -#: ../../include/js_strings.php:87 +#: ../../include/js_strings.php:86 msgid "Thu" msgstr "" -#: ../../include/js_strings.php:88 +#: ../../include/js_strings.php:87 msgid "Fri" msgstr "" -#: ../../include/js_strings.php:89 +#: ../../include/js_strings.php:88 msgid "Sat" msgstr "" -#: ../../include/js_strings.php:90 +#: ../../include/js_strings.php:89 msgctxt "calendar" msgid "today" msgstr "" -#: ../../include/js_strings.php:91 +#: ../../include/js_strings.php:90 msgctxt "calendar" msgid "month" msgstr "" -#: ../../include/js_strings.php:92 +#: ../../include/js_strings.php:91 msgctxt "calendar" msgid "week" msgstr "" -#: ../../include/js_strings.php:93 +#: ../../include/js_strings.php:92 msgctxt "calendar" msgid "day" msgstr "" -#: ../../include/js_strings.php:94 +#: ../../include/js_strings.php:93 msgctxt "calendar" msgid "All day" msgstr "" -#: ../../include/js_strings.php:97 +#: ../../include/js_strings.php:96 msgid "Please stand by while your download is being prepared." msgstr "" -#: ../../include/js_strings.php:100 +#: ../../include/js_strings.php:99 msgid "Email address not valid" msgstr "" -#: ../../include/js_strings.php:101 ../../include/datetime.php:211 +#: ../../include/js_strings.php:100 ../../include/datetime.php:211 #: ../../addon/cart/submodules/orderoptions.php:334 #: ../../addon/cart/submodules/orderoptions.php:358 #: ../../addon/cart/submodules/orderoptions.php:434 @@ -2130,105 +2123,65 @@ msgstr "" msgid "OpenWebAuth: %1$s welcomes %2$s" msgstr "" -#: ../../include/conversation.php:149 ../../include/text.php:2356 +#: ../../include/conversation.php:149 ../../include/text.php:2377 #: ../../addon/redphotos/redphotohelper.php:71 -#: ../../addon/diaspora/Receiver.php:1704 +#: ../../addon/diaspora/Receiver.php:1705 #: ../../Zotlabs/Module/Subthread.php:112 ../../Zotlabs/Module/Tagger.php:73 msgid "photo" msgstr "" -#: ../../include/conversation.php:157 ../../Zotlabs/Module/Like.php:183 +#: ../../include/conversation.php:157 ../../Zotlabs/Module/Like.php:171 msgid "channel" msgstr "" -#: ../../include/conversation.php:180 ../../include/markdown.php:192 -#: ../../include/text.php:2362 ../../include/bbcode.php:572 -#: ../../Zotlabs/Module/Tagger.php:81 -msgid "post" -msgstr "" - -#: ../../include/conversation.php:182 ../../include/text.php:2364 -#: ../../Zotlabs/Module/Tagger.php:83 -msgid "comment" +#: ../../include/conversation.php:180 ../../include/text.php:2385 +msgid "message" msgstr "" -#: ../../include/conversation.php:196 ../../addon/diaspora/Receiver.php:1639 -#: ../../Zotlabs/Module/Like.php:486 +#: ../../include/conversation.php:194 ../../addon/diaspora/Receiver.php:1640 +#: ../../Zotlabs/Module/Like.php:474 #, php-format msgid "%1$s likes %2$s's %3$s" msgstr "" -#: ../../include/conversation.php:198 +#: ../../include/conversation.php:196 #, php-format msgid "likes %1$s's %2$s" msgstr "" -#: ../../include/conversation.php:201 ../../Zotlabs/Module/Like.php:488 +#: ../../include/conversation.php:199 ../../Zotlabs/Module/Like.php:476 #, php-format msgid "%1$s doesn't like %2$s's %3$s" msgstr "" -#: ../../include/conversation.php:202 +#: ../../include/conversation.php:200 #, php-format msgid "doesn't like %1$s's %2$s" msgstr "" -#: ../../include/conversation.php:205 +#: ../../include/conversation.php:203 #, php-format msgid "%1$s repeated %2$s's %3$s" msgstr "" -#: ../../include/conversation.php:206 +#: ../../include/conversation.php:204 #, php-format msgid "repeated %1$s's %2$s" msgstr "" -#: ../../include/conversation.php:334 ../../Zotlabs/Lib/ThreadItem.php:474 +#: ../../include/conversation.php:332 ../../Zotlabs/Lib/ThreadItem.php:472 msgid "This is an unsaved preview" msgstr "" -#: ../../include/conversation.php:471 ../../Zotlabs/Module/Photos.php:1110 -msgctxt "title" -msgid "Likes" -msgstr "" - -#: ../../include/conversation.php:472 ../../Zotlabs/Module/Photos.php:1110 -msgctxt "title" -msgid "Dislikes" -msgstr "" - -#: ../../include/conversation.php:473 ../../Zotlabs/Widget/Pinned.php:73 -#: ../../Zotlabs/Module/Photos.php:1111 -msgctxt "title" -msgid "Attending" -msgstr "" - -#: ../../include/conversation.php:474 ../../Zotlabs/Widget/Pinned.php:74 -#: ../../Zotlabs/Module/Photos.php:1111 -msgctxt "title" -msgid "Not attending" -msgstr "" - -#: ../../include/conversation.php:475 ../../Zotlabs/Widget/Pinned.php:75 -#: ../../Zotlabs/Module/Photos.php:1111 -msgctxt "title" -msgid "Might attend" -msgstr "" - -#: ../../include/conversation.php:477 -msgctxt "title" -msgid "Repeats" -msgstr "" - -#: ../../include/conversation.php:546 +#: ../../include/conversation.php:533 msgid "Select" msgstr "" -#: ../../include/conversation.php:547 ../../include/conversation.php:608 +#: ../../include/conversation.php:534 ../../include/conversation.php:595 #: ../../addon/cards/Mod_Card_edit.php:124 #: ../../addon/articles/Mod_Article_edit.php:124 ../../Zotlabs/Lib/Apps.php:618 -#: ../../Zotlabs/Lib/ThreadItem.php:183 ../../Zotlabs/Lib/ThreadItem.php:482 -#: ../../Zotlabs/Storage/Browser.php:388 +#: ../../Zotlabs/Lib/ThreadItem.php:180 ../../Zotlabs/Lib/ThreadItem.php:480 +#: ../../Zotlabs/Storage/Browser.php:392 #: ../../Zotlabs/Module/Editwebpage.php:167 #: ../../Zotlabs/Module/Webpages.php:251 ../../Zotlabs/Module/Oauth.php:172 #: ../../Zotlabs/Module/Thing.php:302 ../../Zotlabs/Module/Tokens.php:295 @@ -2238,116 +2191,116 @@ msgstr "" #: ../../Zotlabs/Module/Admin/Profs.php:177 #: ../../Zotlabs/Module/Admin/Channels.php:171 #: ../../Zotlabs/Module/Permcats.php:261 ../../Zotlabs/Module/Group.php:252 -#: ../../Zotlabs/Module/Blocks.php:160 ../../Zotlabs/Module/Photos.php:1173 +#: ../../Zotlabs/Module/Blocks.php:160 ../../Zotlabs/Module/Photos.php:1162 #: ../../Zotlabs/Module/Editlayout.php:138 ../../Zotlabs/Module/Cdav.php:1047 #: ../../Zotlabs/Module/Cdav.php:1385 ../../Zotlabs/Module/Oauth2.php:193 #: ../../Zotlabs/Module/Editblock.php:139 msgid "Delete" msgstr "" -#: ../../include/conversation.php:553 ../../Zotlabs/Lib/ThreadItem.php:248 +#: ../../include/conversation.php:540 ../../Zotlabs/Lib/ThreadItem.php:242 msgid "Toggle Star Status" msgstr "" -#: ../../include/conversation.php:559 +#: ../../include/conversation.php:546 msgid "Private Message" msgstr "" -#: ../../include/conversation.php:568 ../../Zotlabs/Lib/ThreadItem.php:258 +#: ../../include/conversation.php:555 ../../Zotlabs/Lib/ThreadItem.php:251 #: ../../Zotlabs/Widget/Pinned.php:84 msgid "Message signature validated" msgstr "" -#: ../../include/conversation.php:569 ../../Zotlabs/Lib/ThreadItem.php:259 +#: ../../include/conversation.php:556 ../../Zotlabs/Lib/ThreadItem.php:252 #: ../../Zotlabs/Widget/Pinned.php:85 msgid "Message signature incorrect" msgstr "" -#: ../../include/conversation.php:607 ../../Zotlabs/Lib/ThreadItem.php:481 +#: ../../include/conversation.php:594 ../../Zotlabs/Lib/ThreadItem.php:479 #: ../../Zotlabs/Module/Admin/Accounts.php:218 #: ../../Zotlabs/Module/Connections.php:358 #: ../../Zotlabs/Module/Connections.php:409 msgid "Approve" msgstr "" -#: ../../include/conversation.php:613 +#: ../../include/conversation.php:600 #, php-format msgid "View %s's profile @ %s" msgstr "" -#: ../../include/conversation.php:635 +#: ../../include/conversation.php:622 msgid "Categories:" msgstr "" -#: ../../include/conversation.php:636 +#: ../../include/conversation.php:623 msgid "Filed under:" msgstr "" -#: ../../include/conversation.php:642 ../../Zotlabs/Lib/ThreadItem.php:414 -#: ../../Zotlabs/Widget/Pinned.php:127 +#: ../../include/conversation.php:629 ../../Zotlabs/Lib/ThreadItem.php:411 +#: ../../Zotlabs/Widget/Pinned.php:130 #, php-format msgid "from %s" msgstr "" -#: ../../include/conversation.php:645 ../../Zotlabs/Widget/Pinned.php:130 +#: ../../include/conversation.php:632 ../../Zotlabs/Widget/Pinned.php:133 #, php-format msgid "last edited: %s" msgstr "" -#: ../../include/conversation.php:646 ../../Zotlabs/Widget/Pinned.php:131 +#: ../../include/conversation.php:633 ../../Zotlabs/Widget/Pinned.php:134 #, php-format msgid "Expires: %s" msgstr "" -#: ../../include/conversation.php:661 ../../addon/cards/cards.php:82 +#: ../../include/conversation.php:648 ../../addon/cards/cards.php:82 #: ../../addon/articles/articles.php:83 msgid "View in context" msgstr "" -#: ../../include/conversation.php:663 ../../Zotlabs/Lib/ThreadItem.php:475 -#: ../../Zotlabs/Module/Photos.php:1077 +#: ../../include/conversation.php:650 ../../Zotlabs/Lib/ThreadItem.php:473 +#: ../../Zotlabs/Module/Photos.php:1078 msgid "Please wait" msgstr "" -#: ../../include/conversation.php:764 +#: ../../include/conversation.php:746 msgid "remove" msgstr "" -#: ../../include/conversation.php:768 +#: ../../include/conversation.php:750 msgid "Loading..." msgstr "" -#: ../../include/conversation.php:769 ../../Zotlabs/Lib/ThreadItem.php:275 +#: ../../include/conversation.php:751 ../../Zotlabs/Lib/ThreadItem.php:268 msgid "Conversation Features" msgstr "" -#: ../../include/conversation.php:770 +#: ../../include/conversation.php:752 msgid "Delete Selected Items" msgstr "" -#: ../../include/conversation.php:806 +#: ../../include/conversation.php:788 msgid "View Source" msgstr "" -#: ../../include/conversation.php:816 +#: ../../include/conversation.php:798 msgid "Follow Thread" msgstr "" -#: ../../include/conversation.php:825 +#: ../../include/conversation.php:807 msgid "Unfollow Thread" msgstr "" -#: ../../include/conversation.php:902 ../../include/nav.php:127 +#: ../../include/conversation.php:884 ../../include/nav.php:127 #: ../../addon/openclipatar/openclipatar.php:58 ../../Zotlabs/Lib/Apps.php:350 #: ../../Zotlabs/Module/Connedit.php:480 msgid "View Profile" msgstr "" -#: ../../include/conversation.php:914 ../../Zotlabs/Module/Connedit.php:501 +#: ../../include/conversation.php:896 ../../Zotlabs/Module/Connedit.php:501 msgid "Recent Activity" msgstr "" -#: ../../include/conversation.php:926 ../../include/connections.php:150 +#: ../../include/conversation.php:908 ../../include/connections.php:150 #: ../../include/channel.php:1627 ../../Zotlabs/Widget/Suggestions.php:51 #: ../../Zotlabs/Widget/Follow.php:37 ../../Zotlabs/Module/Suggest.php:69 #: ../../Zotlabs/Module/Directory.php:371 @@ -2355,209 +2308,198 @@ msgstr "" msgid "Connect" msgstr "" -#: ../../include/conversation.php:938 +#: ../../include/conversation.php:920 msgid "Edit Connection" msgstr "" -#: ../../include/conversation.php:1008 -msgid "Approve this item" -msgstr "" - -#: ../../include/conversation.php:1008 -msgid "Delete this item" -msgstr "" - -#: ../../include/conversation.php:1062 +#: ../../include/conversation.php:949 #, php-format msgid "%s likes this." msgstr "" -#: ../../include/conversation.php:1062 +#: ../../include/conversation.php:949 #, php-format msgid "%s doesn't like this." msgstr "" -#: ../../include/conversation.php:1066 +#: ../../include/conversation.php:953 #, php-format msgid "<span %1$s>%2$d people</span> like this." msgid_plural "<span %1$s>%2$d people</span> like this." msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1068 +#: ../../include/conversation.php:955 #, php-format msgid "<span %1$s>%2$d people</span> don't like this." msgid_plural "<span %1$s>%2$d people</span> don't like this." msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1074 +#: ../../include/conversation.php:961 msgid "and" msgstr "" -#: ../../include/conversation.php:1077 +#: ../../include/conversation.php:964 #, php-format msgid ", and %d other people" msgid_plural ", and %d other people" msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1078 +#: ../../include/conversation.php:965 #, php-format msgid "%s like this." msgstr "" -#: ../../include/conversation.php:1078 +#: ../../include/conversation.php:965 #, php-format msgid "%s don't like this." msgstr "" -#: ../../include/conversation.php:1129 ../../addon/hsse/hsse.php:82 +#: ../../include/conversation.php:1014 ../../addon/hsse/hsse.php:82 msgid "Set your location" msgstr "" -#: ../../include/conversation.php:1130 ../../addon/hsse/hsse.php:83 +#: ../../include/conversation.php:1015 ../../addon/hsse/hsse.php:83 msgid "Clear browser location" msgstr "" -#: ../../include/conversation.php:1142 ../../addon/cards/Mod_Card_edit.php:94 +#: ../../include/conversation.php:1027 ../../addon/cards/Mod_Card_edit.php:94 #: ../../addon/articles/Mod_Article_edit.php:94 ../../addon/hsse/hsse.php:95 #: ../../Zotlabs/Module/Editwebpage.php:143 ../../Zotlabs/Module/Chat.php:219 #: ../../Zotlabs/Module/Editblock.php:116 msgid "Insert web link" msgstr "" -#: ../../include/conversation.php:1146 ../../addon/hsse/hsse.php:99 +#: ../../include/conversation.php:1031 ../../addon/hsse/hsse.php:99 +#: ../../Zotlabs/Lib/ThreadItem.php:816 msgid "Embed (existing) photo from your photo albums" msgstr "" -#: ../../include/conversation.php:1179 ../../addon/hsse/hsse.php:134 +#: ../../include/conversation.php:1064 ../../addon/hsse/hsse.php:134 #: ../../Zotlabs/Module/Chat.php:217 msgid "Please enter a link URL:" msgstr "" -#: ../../include/conversation.php:1180 ../../addon/hsse/hsse.php:135 +#: ../../include/conversation.php:1065 ../../addon/hsse/hsse.php:135 msgid "Tag term:" msgstr "" -#: ../../include/conversation.php:1181 ../../addon/hsse/hsse.php:136 +#: ../../include/conversation.php:1066 ../../addon/hsse/hsse.php:136 msgid "Where are you right now?" msgstr "" -#: ../../include/conversation.php:1184 ../../addon/wiki/Mod_Wiki.php:400 +#: ../../include/conversation.php:1069 ../../addon/wiki/Mod_Wiki.php:400 #: ../../addon/hsse/hsse.php:139 ../../Zotlabs/Module/Cover_photo.php:388 #: ../../Zotlabs/Module/Profile_photo.php:555 msgid "Choose images to embed" msgstr "" -#: ../../include/conversation.php:1185 ../../addon/wiki/Mod_Wiki.php:401 +#: ../../include/conversation.php:1070 ../../addon/wiki/Mod_Wiki.php:401 #: ../../addon/hsse/hsse.php:140 ../../Zotlabs/Module/Cover_photo.php:389 #: ../../Zotlabs/Module/Profile_photo.php:556 msgid "Choose an album" msgstr "" -#: ../../include/conversation.php:1186 ../../addon/hsse/hsse.php:141 +#: ../../include/conversation.php:1071 ../../addon/hsse/hsse.php:141 msgid "Choose a different album..." msgstr "" -#: ../../include/conversation.php:1187 ../../addon/wiki/Mod_Wiki.php:403 +#: ../../include/conversation.php:1072 ../../addon/wiki/Mod_Wiki.php:403 #: ../../addon/hsse/hsse.php:142 ../../Zotlabs/Module/Cover_photo.php:391 #: ../../Zotlabs/Module/Profile_photo.php:558 msgid "Error getting album list" msgstr "" -#: ../../include/conversation.php:1188 ../../addon/wiki/Mod_Wiki.php:404 +#: ../../include/conversation.php:1073 ../../addon/wiki/Mod_Wiki.php:404 #: ../../addon/hsse/hsse.php:143 ../../Zotlabs/Module/Cover_photo.php:392 #: ../../Zotlabs/Module/Profile_photo.php:559 msgid "Error getting photo link" msgstr "" -#: ../../include/conversation.php:1189 ../../addon/wiki/Mod_Wiki.php:405 +#: ../../include/conversation.php:1074 ../../addon/wiki/Mod_Wiki.php:405 #: ../../addon/hsse/hsse.php:144 ../../Zotlabs/Module/Cover_photo.php:393 #: ../../Zotlabs/Module/Profile_photo.php:560 msgid "Error getting album" msgstr "" -#: ../../include/conversation.php:1190 ../../addon/hsse/hsse.php:145 +#: ../../include/conversation.php:1075 ../../addon/hsse/hsse.php:145 msgid "Comments enabled" msgstr "" -#: ../../include/conversation.php:1191 ../../addon/hsse/hsse.php:146 -#: ../../Zotlabs/Lib/ThreadItem.php:472 +#: ../../include/conversation.php:1076 ../../addon/hsse/hsse.php:146 +#: ../../Zotlabs/Lib/ThreadItem.php:470 msgid "Comments disabled" msgstr "" -#: ../../include/conversation.php:1192 +#: ../../include/conversation.php:1077 msgid "Confirm delete" msgstr "" -#: ../../include/conversation.php:1209 ../../addon/hsse/hsse.php:153 -#: ../../Zotlabs/Lib/ThreadItem.php:810 ../../Zotlabs/Module/Webpages.php:256 -#: ../../Zotlabs/Module/Photos.php:1096 +#: ../../include/conversation.php:1094 ../../addon/hsse/hsse.php:153 +#: ../../Zotlabs/Lib/ThreadItem.php:820 ../../Zotlabs/Module/Webpages.php:256 +#: ../../Zotlabs/Module/Photos.php:1097 msgid "Preview" msgstr "" -#: ../../include/conversation.php:1242 ../../addon/wiki/Mod_Wiki.php:304 -#: ../../addon/hsse/hsse.php:186 ../../Zotlabs/Lib/ThreadItem.php:305 -#: ../../Zotlabs/Widget/Cdav.php:142 ../../Zotlabs/Module/Webpages.php:250 -#: ../../Zotlabs/Module/Layouts.php:192 ../../Zotlabs/Module/Blocks.php:159 -#: ../../Zotlabs/Module/Photos.php:1076 -msgid "Share" +#: ../../include/conversation.php:1128 +msgid "Start a conversation" msgstr "" -#: ../../include/conversation.php:1251 ../../addon/hsse/hsse.php:195 +#: ../../include/conversation.php:1136 ../../addon/hsse/hsse.php:195 msgid "Page link name" msgstr "" -#: ../../include/conversation.php:1254 ../../addon/hsse/hsse.php:198 +#: ../../include/conversation.php:1139 ../../addon/hsse/hsse.php:198 msgid "Post as" msgstr "" -#: ../../include/conversation.php:1256 ../../addon/hsse/hsse.php:200 -#: ../../Zotlabs/Lib/ThreadItem.php:800 +#: ../../include/conversation.php:1141 ../../addon/hsse/hsse.php:200 +#: ../../Zotlabs/Lib/ThreadItem.php:810 msgid "Bold" msgstr "" -#: ../../include/conversation.php:1257 ../../addon/hsse/hsse.php:201 -#: ../../Zotlabs/Lib/ThreadItem.php:801 +#: ../../include/conversation.php:1142 ../../addon/hsse/hsse.php:201 +#: ../../Zotlabs/Lib/ThreadItem.php:811 msgid "Italic" msgstr "" -#: ../../include/conversation.php:1258 ../../Zotlabs/Lib/ThreadItem.php:802 +#: ../../include/conversation.php:1143 ../../Zotlabs/Lib/ThreadItem.php:812 msgid "Highlight selected text" msgstr "" -#: ../../include/conversation.php:1259 ../../addon/hsse/hsse.php:202 -#: ../../Zotlabs/Lib/ThreadItem.php:803 +#: ../../include/conversation.php:1144 ../../addon/hsse/hsse.php:202 +#: ../../Zotlabs/Lib/ThreadItem.php:813 msgid "Underline" msgstr "" -#: ../../include/conversation.php:1260 ../../addon/hsse/hsse.php:203 -#: ../../Zotlabs/Lib/ThreadItem.php:804 +#: ../../include/conversation.php:1145 ../../addon/hsse/hsse.php:203 +#: ../../Zotlabs/Lib/ThreadItem.php:814 msgid "Quote" msgstr "" -#: ../../include/conversation.php:1261 ../../addon/hsse/hsse.php:204 -#: ../../Zotlabs/Lib/ThreadItem.php:805 +#: ../../include/conversation.php:1146 ../../addon/hsse/hsse.php:204 +#: ../../Zotlabs/Lib/ThreadItem.php:815 msgid "Code" msgstr "" -#: ../../include/conversation.php:1262 ../../addon/hsse/hsse.php:205 -#: ../../Zotlabs/Lib/ThreadItem.php:807 +#: ../../include/conversation.php:1147 ../../addon/hsse/hsse.php:205 +#: ../../Zotlabs/Lib/ThreadItem.php:817 msgid "Attach/Upload file" msgstr "" -#: ../../include/conversation.php:1265 ../../addon/wiki/Mod_Wiki.php:397 +#: ../../include/conversation.php:1150 ../../addon/wiki/Mod_Wiki.php:397 #: ../../addon/hsse/hsse.php:208 msgid "Embed an image from your albums" msgstr "" -#: ../../include/conversation.php:1266 ../../include/conversation.php:1321 +#: ../../include/conversation.php:1151 ../../include/conversation.php:1206 #: ../../addon/cards/Mod_Card_edit.php:126 #: ../../addon/articles/Mod_Article_edit.php:126 #: ../../addon/wiki/Mod_Wiki.php:365 ../../addon/wiki/Mod_Wiki.php:398 #: ../../addon/hsse/hsse.php:209 ../../addon/hsse/hsse.php:258 -#: ../../Zotlabs/Storage/Browser.php:387 +#: ../../Zotlabs/Storage/Browser.php:391 #: ../../Zotlabs/Module/Cover_photo.php:386 #: ../../Zotlabs/Module/Editwebpage.php:169 ../../Zotlabs/Module/Oauth.php:111 #: ../../Zotlabs/Module/Oauth.php:136 ../../Zotlabs/Module/Connedit.php:750 @@ -2571,118 +2513,132 @@ msgstr "" msgid "Cancel" msgstr "" -#: ../../include/conversation.php:1267 ../../include/conversation.php:1320 +#: ../../include/conversation.php:1152 ../../include/conversation.php:1205 #: ../../addon/wiki/Mod_Wiki.php:399 ../../addon/hsse/hsse.php:210 #: ../../addon/hsse/hsse.php:257 ../../Zotlabs/Module/Cover_photo.php:387 #: ../../Zotlabs/Module/Profile_photo.php:554 msgid "OK" msgstr "" -#: ../../include/conversation.php:1269 ../../addon/hsse/hsse.php:212 +#: ../../include/conversation.php:1154 ../../addon/hsse/hsse.php:212 msgid "Toggle voting" msgstr "" -#: ../../include/conversation.php:1270 +#: ../../include/conversation.php:1155 msgid "Toggle poll" msgstr "" -#: ../../include/conversation.php:1271 +#: ../../include/conversation.php:1156 msgid "Option" msgstr "" -#: ../../include/conversation.php:1272 +#: ../../include/conversation.php:1157 msgid "Add option" msgstr "" -#: ../../include/conversation.php:1273 +#: ../../include/conversation.php:1158 msgid "Minutes" msgstr "" -#: ../../include/conversation.php:1273 +#: ../../include/conversation.php:1158 msgid "Hours" msgstr "" -#: ../../include/conversation.php:1273 +#: ../../include/conversation.php:1158 msgid "Days" msgstr "" -#: ../../include/conversation.php:1274 +#: ../../include/conversation.php:1159 msgid "Allow multiple answers" msgstr "" -#: ../../include/conversation.php:1276 ../../addon/hsse/hsse.php:215 +#: ../../include/conversation.php:1161 ../../addon/hsse/hsse.php:215 msgid "Disable comments" msgstr "" -#: ../../include/conversation.php:1277 ../../addon/hsse/hsse.php:216 +#: ../../include/conversation.php:1162 ../../addon/hsse/hsse.php:216 msgid "Toggle comments" msgstr "" -#: ../../include/conversation.php:1283 ../../addon/cards/Mod_Card_edit.php:111 +#: ../../include/conversation.php:1168 ../../addon/cards/Mod_Card_edit.php:111 #: ../../addon/articles/Mod_Article_edit.php:111 ../../addon/hsse/hsse.php:221 -#: ../../Zotlabs/Module/Photos.php:667 ../../Zotlabs/Module/Photos.php:1042 +#: ../../Zotlabs/Module/Photos.php:669 ../../Zotlabs/Module/Photos.php:1043 #: ../../Zotlabs/Module/Editblock.php:129 msgid "Title (optional)" msgstr "" -#: ../../include/conversation.php:1284 +#: ../../include/conversation.php:1169 msgid "Summary (optional)" msgstr "" -#: ../../include/conversation.php:1287 ../../addon/hsse/hsse.php:224 +#: ../../include/conversation.php:1172 ../../addon/hsse/hsse.php:224 msgid "Categories (optional, comma-separated list)" msgstr "" -#: ../../include/conversation.php:1288 ../../addon/hsse/hsse.php:225 +#: ../../include/conversation.php:1173 ../../addon/hsse/hsse.php:225 msgid "Permission settings" msgstr "" -#: ../../include/conversation.php:1310 ../../addon/hsse/hsse.php:247 +#: ../../include/conversation.php:1195 ../../addon/hsse/hsse.php:247 msgid "Other networks and post services" msgstr "" -#: ../../include/conversation.php:1313 ../../addon/hsse/hsse.php:250 +#: ../../include/conversation.php:1198 ../../addon/hsse/hsse.php:250 msgid "Set expiration date" msgstr "" -#: ../../include/conversation.php:1316 ../../addon/hsse/hsse.php:253 +#: ../../include/conversation.php:1201 ../../addon/hsse/hsse.php:253 msgid "Set publish date" msgstr "" -#: ../../include/conversation.php:1318 ../../addon/hsse/hsse.php:255 -#: ../../Zotlabs/Lib/ThreadItem.php:813 ../../Zotlabs/Module/Chat.php:218 +#: ../../include/conversation.php:1203 ../../addon/hsse/hsse.php:255 +#: ../../Zotlabs/Lib/ThreadItem.php:823 ../../Zotlabs/Module/Chat.php:218 msgid "Encrypt text" msgstr "" -#: ../../include/conversation.php:1564 +#: ../../include/conversation.php:1443 msgctxt "noun" msgid "Repeat" msgid_plural "Repeats" msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1567 ../../Zotlabs/Module/Photos.php:1134 +#: ../../include/conversation.php:1446 ../../Zotlabs/Module/Photos.php:1123 msgctxt "noun" msgid "Dislike" msgid_plural "Dislikes" msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1570 +#: ../../include/conversation.php:1449 +msgctxt "noun" +msgid "Comment" +msgid_plural "Comments" +msgstr[0] "" +msgstr[1] "" + +#: ../../include/conversation.php:1449 +msgctxt "noun" +msgid "Reply" +msgid_plural "Replies" +msgstr[0] "" +msgstr[1] "" + +#: ../../include/conversation.php:1452 msgctxt "noun" msgid "Attending" msgid_plural "Attending" msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1573 +#: ../../include/conversation.php:1455 msgctxt "noun" -msgid "Not Attending" -msgid_plural "Not Attending" +msgid "Not attending" +msgid_plural "Not attending" msgstr[0] "" msgstr[1] "" -#: ../../include/conversation.php:1576 +#: ../../include/conversation.php:1458 msgctxt "noun" msgid "Undecided" msgid_plural "Undecided" @@ -2721,7 +2677,7 @@ msgid "Account/Channel Settings" msgstr "" #: ../../include/nav.php:124 ../../include/nav.php:154 -#: ../../include/nav.php:175 ../../boot.php:1753 +#: ../../include/nav.php:175 ../../boot.php:1760 msgid "Logout" msgstr "" @@ -2751,8 +2707,8 @@ msgstr "" msgid "Edit your profile" msgstr "" -#: ../../include/nav.php:139 ../../include/nav.php:143 ../../boot.php:1754 -#: ../../Zotlabs/Lib/Apps.php:342 +#: ../../include/nav.php:139 ../../include/nav.php:143 ../../boot.php:1761 +#: ../../Zotlabs/Lib/Apps.php:342 ../../Zotlabs/Module/Login.php:15 msgid "Login" msgstr "" @@ -2768,7 +2724,7 @@ msgstr "" msgid "Log me out of this site" msgstr "" -#: ../../include/nav.php:180 ../../boot.php:1731 +#: ../../include/nav.php:180 ../../boot.php:1738 #: ../../Zotlabs/Module/Register.php:543 msgid "Register" msgstr "" @@ -2807,7 +2763,7 @@ msgid "Site Setup and Configuration" msgstr "" #: ../../include/nav.php:345 ../../Zotlabs/Widget/Notifications.php:175 -#: ../../Zotlabs/Widget/Messages.php:50 ../../Zotlabs/Module/Defperms.php:254 +#: ../../Zotlabs/Widget/Messages.php:52 ../../Zotlabs/Module/Defperms.php:254 #: ../../Zotlabs/Module/New_channel.php:158 #: ../../Zotlabs/Module/New_channel.php:165 msgid "Loading" @@ -2842,6 +2798,7 @@ msgid "Featured Apps" msgstr "" #: ../../include/nav.php:447 ../../Zotlabs/Lib/Apps.php:349 +#: ../../Zotlabs/Widget/Notifications.php:43 #: ../../Zotlabs/Module/Admin/Channels.php:176 msgid "Channel" msgstr "" @@ -2865,7 +2822,7 @@ msgstr "" #: ../../include/nav.php:478 ../../Zotlabs/Lib/Apps.php:346 #: ../../Zotlabs/Widget/Notifications.php:108 #: ../../Zotlabs/Widget/Channel_activities.php:125 -#: ../../Zotlabs/Storage/Browser.php:351 ../../Zotlabs/Module/Fbrowser.php:87 +#: ../../Zotlabs/Storage/Browser.php:355 ../../Zotlabs/Module/Fbrowser.php:87 msgid "Files" msgstr "" @@ -2920,7 +2877,7 @@ msgstr "" msgid "YYYY-MM-DD or MM-DD" msgstr "" -#: ../../include/datetime.php:238 ../../boot.php:2768 +#: ../../include/datetime.php:238 ../../boot.php:2680 msgid "never" msgstr "" @@ -3033,8 +2990,8 @@ msgctxt "photo_upload" msgid "%1$s posted %2$s to %3$s" msgstr "" -#: ../../include/photos.php:748 ../../Zotlabs/Module/Photos.php:1339 -#: ../../Zotlabs/Module/Photos.php:1352 ../../Zotlabs/Module/Photos.php:1353 +#: ../../include/photos.php:748 ../../Zotlabs/Module/Photos.php:1333 +#: ../../Zotlabs/Module/Photos.php:1346 ../../Zotlabs/Module/Photos.php:1347 msgid "Recent Photos" msgstr "" @@ -3066,27 +3023,27 @@ msgstr "" msgid "content-type: " msgstr "" -#: ../../include/network.php:1775 ../../include/network.php:1776 +#: ../../include/network.php:1774 ../../include/network.php:1775 msgid "Friendica" msgstr "" -#: ../../include/network.php:1777 +#: ../../include/network.php:1776 msgid "OStatus" msgstr "" -#: ../../include/network.php:1778 +#: ../../include/network.php:1777 msgid "GNU-Social" msgstr "" -#: ../../include/network.php:1779 +#: ../../include/network.php:1778 msgid "RSS/Atom" msgstr "" -#: ../../include/network.php:1780 +#: ../../include/network.php:1779 msgid "ActivityPub" msgstr "" -#: ../../include/network.php:1781 ../../addon/openid/MysqlProvider.php:56 +#: ../../include/network.php:1780 ../../addon/openid/MysqlProvider.php:56 #: ../../addon/openid/MysqlProvider.php:57 ../../addon/redred/Mod_Redred.php:69 #: ../../addon/rtof/Mod_Rtof.php:55 ../../Zotlabs/Module/Connedit.php:736 #: ../../Zotlabs/Module/Admin/Accounts.php:216 @@ -3095,27 +3052,27 @@ msgstr "" msgid "Email" msgstr "" -#: ../../include/network.php:1782 +#: ../../include/network.php:1781 msgid "Diaspora" msgstr "" -#: ../../include/network.php:1783 +#: ../../include/network.php:1782 msgid "Facebook" msgstr "" -#: ../../include/network.php:1784 +#: ../../include/network.php:1783 msgid "Zot" msgstr "" -#: ../../include/network.php:1785 +#: ../../include/network.php:1784 msgid "LinkedIn" msgstr "" -#: ../../include/network.php:1786 +#: ../../include/network.php:1785 msgid "XMPP/IM" msgstr "" -#: ../../include/network.php:1787 +#: ../../include/network.php:1786 msgid "MySpace" msgstr "" @@ -3124,23 +3081,20 @@ msgstr "" msgid "%1$s wrote the following %2$s %3$s" msgstr "" -#: ../../include/markdown.php:262 ../../include/bbcode.php:661 -msgid "spoiler" -msgstr "" - -#: ../../include/language.php:423 ../../include/text.php:2197 -msgid "default" +#: ../../include/markdown.php:192 ../../include/bbcode.php:572 +#: ../../Zotlabs/Module/Tagger.php:81 +msgid "post" msgstr "" -#: ../../include/language.php:436 -msgid "Select an alternate language" +#: ../../include/markdown.php:262 ../../include/bbcode.php:661 +msgid "spoiler" msgstr "" #: ../../include/menu.php:120 ../../include/channel.php:1541 #: ../../include/channel.php:1545 ../../addon/cards/cards.php:74 #: ../../addon/articles/articles.php:75 ../../addon/wiki/Mod_Wiki.php:214 #: ../../addon/wiki/Mod_Wiki.php:381 ../../Zotlabs/Lib/Apps.php:617 -#: ../../Zotlabs/Lib/ThreadItem.php:162 ../../Zotlabs/Widget/Cdav.php:144 +#: ../../Zotlabs/Lib/ThreadItem.php:159 ../../Zotlabs/Widget/Cdav.php:144 #: ../../Zotlabs/Widget/Cdav.php:181 ../../Zotlabs/Module/Editwebpage.php:142 #: ../../Zotlabs/Module/Webpages.php:249 ../../Zotlabs/Module/Oauth.php:171 #: ../../Zotlabs/Module/Thing.php:301 ../../Zotlabs/Module/Layouts.php:191 @@ -3169,7 +3123,6 @@ msgstr "" #: ../../include/acl_selectors.php:125 #: ../../Zotlabs/Widget/Notifications.php:131 -#: ../../Zotlabs/Widget/Notifications.php:132 #: ../../Zotlabs/Widget/Activity_filter.php:130 #: ../../Zotlabs/Widget/Forums.php:77 msgid "Forums" @@ -3203,17 +3156,16 @@ msgstr "" msgid "Don't allow" msgstr "" -#: ../../include/acl_selectors.php:154 -#: ../../addon/flashcards/Mod_Flashcards.php:261 -#: ../../Zotlabs/Module/Thing.php:357 ../../Zotlabs/Module/Thing.php:407 -#: ../../Zotlabs/Module/Filestorage.php:195 ../../Zotlabs/Module/Photos.php:671 -#: ../../Zotlabs/Module/Photos.php:1045 ../../Zotlabs/Module/Chat.php:240 +#: ../../include/acl_selectors.php:154 ../../Zotlabs/Module/Thing.php:357 +#: ../../Zotlabs/Module/Thing.php:407 ../../Zotlabs/Module/Filestorage.php:195 +#: ../../Zotlabs/Module/Photos.php:673 ../../Zotlabs/Module/Photos.php:1046 +#: ../../Zotlabs/Module/Chat.php:240 msgid "Permissions" msgstr "" -#: ../../include/acl_selectors.php:156 ../../Zotlabs/Lib/ThreadItem.php:470 -#: ../../Zotlabs/Widget/Pinned.php:153 ../../Zotlabs/Storage/Browser.php:414 -#: ../../Zotlabs/Module/Photos.php:1266 +#: ../../include/acl_selectors.php:156 ../../Zotlabs/Lib/ThreadItem.php:467 +#: ../../Zotlabs/Widget/Pinned.php:156 ../../Zotlabs/Storage/Browser.php:418 +#: ../../Zotlabs/Module/Photos.php:1260 msgid "Close" msgstr "" @@ -3294,33 +3246,33 @@ msgstr "" msgid "Save" msgstr "" -#: ../../include/text.php:1503 +#: ../../include/text.php:1525 msgid "May" msgstr "" -#: ../../include/text.php:1577 +#: ../../include/text.php:1599 msgid "Unknown attachment" msgstr "" -#: ../../include/text.php:1580 ../../Zotlabs/Storage/Browser.php:383 +#: ../../include/text.php:1602 ../../Zotlabs/Storage/Browser.php:387 #: ../../Zotlabs/Module/Sharedwithme.php:109 msgid "Size" msgstr "" -#: ../../include/text.php:1621 +#: ../../include/text.php:1643 msgid "remove category" msgstr "" -#: ../../include/text.php:1699 +#: ../../include/text.php:1721 msgid "remove from file" msgstr "" -#: ../../include/text.php:1886 +#: ../../include/text.php:1908 msgid "Download binary/encrypted content" msgstr "" -#: ../../include/text.php:1944 ../../include/text.php:1953 -#: ../../include/text.php:1980 ../../include/text.php:1989 +#: ../../include/text.php:1966 ../../include/text.php:1975 +#: ../../include/text.php:2002 ../../include/text.php:2011 #, php-format msgctxt "noun" msgid "%d Vote" @@ -3328,7 +3280,7 @@ msgid_plural "%d Votes" msgstr[0] "" msgstr[1] "" -#: ../../include/text.php:1996 +#: ../../include/text.php:2018 #, php-format msgctxt "noun" msgid "%d Vote in total" @@ -3336,157 +3288,165 @@ msgid_plural "%d Votes in total" msgstr[0] "" msgstr[1] "" -#: ../../include/text.php:2002 +#: ../../include/text.php:2024 msgid "Poll has ended" msgstr "" -#: ../../include/text.php:2005 +#: ../../include/text.php:2027 #, php-format -msgid "Poll ends in %s" +msgid "Poll ends %s" msgstr "" -#: ../../include/text.php:2012 ../../Zotlabs/Lib/ThreadItem.php:430 +#: ../../include/text.php:2034 ../../Zotlabs/Lib/ThreadItem.php:427 msgid "Vote" msgstr "" -#: ../../include/text.php:2172 +#: ../../include/text.php:2193 msgid "Link to Source" msgstr "" -#: ../../include/text.php:2205 +#: ../../include/text.php:2218 ../../Zotlabs/Module/Lang.php:75 +msgid "default" +msgstr "" + +#: ../../include/text.php:2226 msgid "Page layout" msgstr "" -#: ../../include/text.php:2205 +#: ../../include/text.php:2226 msgid "You can create your own with the layouts tool" msgstr "" -#: ../../include/text.php:2215 ../../addon/wiki/Mod_Wiki.php:220 +#: ../../include/text.php:2236 ../../addon/wiki/Mod_Wiki.php:220 #: ../../addon/wiki/Mod_Wiki.php:368 ../../addon/wiki/Mod_Wiki.php:903 #: ../../addon/wiki/Widget/Wiki_pages.php:68 msgid "BBcode" msgstr "" -#: ../../include/text.php:2216 +#: ../../include/text.php:2237 msgid "HTML" msgstr "" -#: ../../include/text.php:2217 ../../addon/wiki/Mod_Wiki.php:220 +#: ../../include/text.php:2238 ../../addon/wiki/Mod_Wiki.php:220 #: ../../addon/wiki/Mod_Wiki.php:368 ../../addon/wiki/Mod_Wiki.php:903 #: ../../addon/wiki/Widget/Wiki_pages.php:68 ../../addon/mdpost/mdpost.php:41 msgid "Markdown" msgstr "" -#: ../../include/text.php:2218 ../../addon/wiki/Mod_Wiki.php:220 +#: ../../include/text.php:2239 ../../addon/wiki/Mod_Wiki.php:220 #: ../../addon/wiki/Mod_Wiki.php:903 ../../addon/wiki/Widget/Wiki_pages.php:68 msgid "Text" msgstr "" -#: ../../include/text.php:2219 +#: ../../include/text.php:2240 msgid "Comanche Layout" msgstr "" -#: ../../include/text.php:2224 +#: ../../include/text.php:2245 msgid "PHP" msgstr "" -#: ../../include/text.php:2236 +#: ../../include/text.php:2257 msgid "Page content type" msgstr "" -#: ../../include/text.php:2369 +#: ../../include/text.php:2383 +msgid "conversation" +msgstr "" + +#: ../../include/text.php:2390 msgid "activity" msgstr "" -#: ../../include/text.php:2372 +#: ../../include/text.php:2394 msgid "poll" msgstr "" -#: ../../include/text.php:2485 +#: ../../include/text.php:2508 msgid "a-z, 0-9, -, and _ only" msgstr "" -#: ../../include/text.php:2793 +#: ../../include/text.php:2818 msgid "Design Tools" msgstr "" -#: ../../include/text.php:2796 ../../Zotlabs/Module/Blocks.php:152 +#: ../../include/text.php:2821 ../../Zotlabs/Module/Blocks.php:152 msgid "Blocks" msgstr "" -#: ../../include/text.php:2797 ../../Zotlabs/Module/Menu.php:171 +#: ../../include/text.php:2822 ../../Zotlabs/Module/Menu.php:171 msgid "Menus" msgstr "" -#: ../../include/text.php:2798 ../../Zotlabs/Module/Layouts.php:182 +#: ../../include/text.php:2823 ../../Zotlabs/Module/Layouts.php:182 msgid "Layouts" msgstr "" -#: ../../include/text.php:2799 +#: ../../include/text.php:2824 msgid "Pages" msgstr "" -#: ../../include/text.php:2811 +#: ../../include/text.php:2836 msgid "Import" msgstr "" -#: ../../include/text.php:2812 +#: ../../include/text.php:2837 msgid "Import website..." msgstr "" -#: ../../include/text.php:2813 +#: ../../include/text.php:2838 msgid "Select folder to import" msgstr "" -#: ../../include/text.php:2814 +#: ../../include/text.php:2839 msgid "Import from a zipped folder:" msgstr "" -#: ../../include/text.php:2815 +#: ../../include/text.php:2840 msgid "Import from cloud files:" msgstr "" -#: ../../include/text.php:2816 +#: ../../include/text.php:2841 msgid "/cloud/channel/path/to/folder" msgstr "" -#: ../../include/text.php:2817 +#: ../../include/text.php:2842 msgid "Enter path to website files" msgstr "" -#: ../../include/text.php:2818 +#: ../../include/text.php:2843 msgid "Select folder" msgstr "" -#: ../../include/text.php:2819 +#: ../../include/text.php:2844 msgid "Export website..." msgstr "" -#: ../../include/text.php:2820 +#: ../../include/text.php:2845 msgid "Export to a zip file" msgstr "" -#: ../../include/text.php:2821 +#: ../../include/text.php:2846 msgid "website.zip" msgstr "" -#: ../../include/text.php:2822 +#: ../../include/text.php:2847 msgid "Enter a name for the zip file." msgstr "" -#: ../../include/text.php:2823 +#: ../../include/text.php:2848 msgid "Export to cloud files" msgstr "" -#: ../../include/text.php:2824 +#: ../../include/text.php:2849 msgid "/path/to/export/folder" msgstr "" -#: ../../include/text.php:2825 +#: ../../include/text.php:2850 msgid "Enter a path to a cloud files destination." msgstr "" -#: ../../include/text.php:2826 +#: ../../include/text.php:2851 msgid "Specify folder" msgstr "" @@ -3539,6 +3499,7 @@ msgstr "" #: ../../include/channel.php:1438 ../../addon/cards/Mod_Cards.php:42 #: ../../addon/articles/Mod_Articles.php:46 +#: ../../addon/flashcards/Mod_Flashcards.php:74 #: ../../addon/gallery/Mod_Gallery.php:49 #: ../../Zotlabs/Module/Editwebpage.php:32 ../../Zotlabs/Module/Webpages.php:39 #: ../../Zotlabs/Module/Connect.php:17 ../../Zotlabs/Module/Filestorage.php:59 @@ -3713,7 +3674,7 @@ msgstr "" msgid "cover photo" msgstr "" -#: ../../include/channel.php:2628 ../../boot.php:1755 +#: ../../include/channel.php:2628 ../../boot.php:1762 #: ../../Zotlabs/Module/Rmagic.php:96 msgid "Remote Authentication" msgstr "" @@ -3732,7 +3693,7 @@ msgid "Account '%s' deleted" msgstr "" #: ../../include/bbcode.php:234 ../../include/bbcode.php:994 -#: ../../include/bbcode.php:1663 ../../include/bbcode.php:1671 +#: ../../include/bbcode.php:1676 ../../include/bbcode.php:1684 msgid "Image/photo" msgstr "" @@ -3793,7 +3754,7 @@ msgstr "" msgid "Different viewers will see this text differently" msgstr "" -#: ../../include/bbcode.php:1639 +#: ../../include/bbcode.php:1652 msgid "$1 wrote:" msgstr "" @@ -4056,7 +4017,7 @@ msgid "Last Name" msgstr "" #: ../../addon/openid/MysqlProvider.php:54 ../../addon/redred/Mod_Redred.php:73 -#: ../../boot.php:1748 +#: ../../boot.php:1755 msgid "Nickname" msgstr "" @@ -4306,9 +4267,9 @@ msgid "$Projectname" msgstr "" #: ../../addon/opensearch/opensearch.php:42 ../../Zotlabs/Lib/Enotify.php:67 -#: ../../Zotlabs/Module/Home.php:88 ../../Zotlabs/Module/Home.php:96 -#: ../../Zotlabs/Module/Invite.php:239 ../../Zotlabs/Module/Invite.php:508 -#: ../../Zotlabs/Module/Invite.php:522 +#: ../../Zotlabs/Module/Home.php:92 ../../Zotlabs/Module/Home.php:100 +#: ../../Zotlabs/Module/Invite.php:239 ../../Zotlabs/Module/Invite.php:491 +#: ../../Zotlabs/Module/Invite.php:505 msgid "$Projectname" msgstr "" @@ -4545,7 +4506,7 @@ msgstr "" msgid "Channel is required." msgstr "" -#: ../../addon/redred/Mod_Redred.php:29 ../../Zotlabs/Module/Network.php:333 +#: ../../addon/redred/Mod_Redred.php:29 ../../Zotlabs/Module/Network.php:317 msgid "Invalid channel." msgstr "" @@ -4581,7 +4542,7 @@ msgstr "" msgid "Hubzilla Crosspost Connector" msgstr "" -#: ../../addon/cards/cards.php:48 ../../addon/cards/cards.php:160 +#: ../../addon/cards/cards.php:48 ../../addon/cards/cards.php:161 #: ../../addon/cards/Mod_Cards.php:209 ../../Zotlabs/Lib/Apps.php:332 msgid "Cards" msgstr "" @@ -4594,7 +4555,7 @@ msgstr "" #: ../../addon/wiki/Lib/NativeWikiPage.php:549 #: ../../Zotlabs/Module/Page.php:136 ../../Zotlabs/Module/Display.php:155 #: ../../Zotlabs/Module/Block.php:77 ../../Zotlabs/Module/Help.php:173 -#: ../../Zotlabs/Web/Router.php:188 +#: ../../Zotlabs/Web/Router.php:194 msgid "Page not found." msgstr "" @@ -4688,41 +4649,29 @@ msgstr "" msgid "Your test account is about to expire." msgstr "" -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:28 -msgid "ActivityPub Protocol Settings updated." -msgstr "" - -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:44 +#: ../../addon/pubcrawl/Mod_Pubcrawl.php:24 msgid "" "The activitypub protocol does not support location independence. Connections " "you make within that network may be unreachable from alternate channel " "locations." msgstr "" -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:50 -msgid "Send activities of type note instead of article" -msgstr "" - -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:50 -msgid "Microblog services such as Mastodon do not properly support articles" -msgstr "" - -#: ../../addon/pubcrawl/Mod_Pubcrawl.php:58 +#: ../../addon/pubcrawl/Mod_Pubcrawl.php:31 msgid "Activitypub Protocol" msgstr "" -#: ../../addon/pubcrawl/pubcrawl.php:1099 ../../addon/diaspora/diaspora.php:415 +#: ../../addon/pubcrawl/pubcrawl.php:1099 ../../addon/diaspora/diaspora.php:417 #: ../../Zotlabs/Module/Contactedit.php:494 msgid "Refresh failed" msgstr "" -#: ../../addon/pubcrawl/pubcrawl.php:1106 ../../addon/diaspora/diaspora.php:420 +#: ../../addon/pubcrawl/pubcrawl.php:1106 ../../addon/diaspora/diaspora.php:422 #: ../../Zotlabs/Module/Contactedit.php:491 msgid "Refresh succeeded" msgstr "" #: ../../addon/bookmarker/bookmarker.php:38 -#: ../../Zotlabs/Lib/ThreadItem.php:458 +#: ../../Zotlabs/Lib/ThreadItem.php:455 msgid "Save Bookmarks" msgstr "" @@ -4791,7 +4740,7 @@ msgstr "" msgid "Diaspora relay could not be imported" msgstr "" -#: ../../addon/diaspora/diaspora.php:1110 +#: ../../addon/diaspora/diaspora.php:1112 msgid "No subject" msgstr "" @@ -4816,27 +4765,27 @@ msgstr "" msgid "$projectname" msgstr "" -#: ../../addon/diaspora/Receiver.php:1643 +#: ../../addon/diaspora/Receiver.php:1644 #, php-format msgid "%1$s dislikes %2$s's %3$s" msgstr "" -#: ../../addon/diaspora/Receiver.php:1704 -#: ../../Zotlabs/Module/Subthread.php:112 ../../Zotlabs/Module/Like.php:459 +#: ../../addon/diaspora/Receiver.php:1705 +#: ../../Zotlabs/Module/Subthread.php:112 ../../Zotlabs/Module/Like.php:447 msgid "status" msgstr "" -#: ../../addon/diaspora/Receiver.php:2265 ../../Zotlabs/Module/Like.php:490 +#: ../../addon/diaspora/Receiver.php:2266 ../../Zotlabs/Module/Like.php:478 #, php-format msgid "%1$s is attending %2$s's %3$s" msgstr "" -#: ../../addon/diaspora/Receiver.php:2267 ../../Zotlabs/Module/Like.php:492 +#: ../../addon/diaspora/Receiver.php:2268 ../../Zotlabs/Module/Like.php:480 #, php-format msgid "%1$s is not attending %2$s's %3$s" msgstr "" -#: ../../addon/diaspora/Receiver.php:2269 ../../Zotlabs/Module/Like.php:494 +#: ../../addon/diaspora/Receiver.php:2270 ../../Zotlabs/Module/Like.php:482 #, php-format msgid "%1$s may attend %2$s's %3$s" msgstr "" @@ -4896,28 +4845,32 @@ msgstr "" msgid "Enter some text" msgstr "" -#: ../../addon/superblock/Mod_Superblock.php:62 +#: ../../addon/superblock/Mod_Superblock.php:117 msgid "superblock settings updated" msgstr "" -#: ../../addon/superblock/Mod_Superblock.php:86 +#: ../../addon/superblock/Mod_Superblock.php:141 msgid "Currently blocked" msgstr "" -#: ../../addon/superblock/Mod_Superblock.php:88 +#: ../../addon/superblock/Mod_Superblock.php:143 msgid "No channels currently blocked" msgstr "" -#: ../../addon/superblock/Mod_Superblock.php:90 +#: ../../addon/superblock/Mod_Superblock.php:145 #: ../../Zotlabs/Module/Cover_photo.php:382 ../../Zotlabs/Module/Tagrm.php:137 -#: ../../Zotlabs/Module/Photos.php:994 +#: ../../Zotlabs/Module/Photos.php:995 msgid "Remove" msgstr "" -#: ../../addon/superblock/superblock.php:355 +#: ../../addon/superblock/superblock.php:378 msgid "Block Completely" msgstr "" +#: ../../addon/superblock/superblock.php:387 +msgid "Block from site" +msgstr "" + #: ../../addon/randpost/randpost.php:101 msgid "You're welcome." msgstr "" @@ -5051,7 +5004,7 @@ msgstr "" #: ../../addon/rendezvous/rendezvous.php:172 ../../addon/wiki/Mod_Wiki.php:221 #: ../../addon/wiki/Lib/NativeWikiPage.php:592 #: ../../addon/wiki/Widget/Wiki_page_history.php:28 -#: ../../Zotlabs/Storage/Browser.php:381 ../../Zotlabs/Module/Oauth.php:112 +#: ../../Zotlabs/Storage/Browser.php:385 ../../Zotlabs/Module/Oauth.php:112 #: ../../Zotlabs/Module/Oauth.php:137 ../../Zotlabs/Module/Connedit.php:732 #: ../../Zotlabs/Module/Admin/Channels.php:181 #: ../../Zotlabs/Module/Sharedwithme.php:107 ../../Zotlabs/Module/Chat.php:256 @@ -5251,7 +5204,7 @@ msgstr "" msgid "Edit Article" msgstr "" -#: ../../addon/articles/articles.php:48 ../../addon/articles/articles.php:160 +#: ../../addon/articles/articles.php:48 ../../addon/articles/articles.php:161 #: ../../addon/articles/Mod_Articles.php:228 ../../Zotlabs/Lib/Apps.php:331 msgid "Articles" msgstr "" @@ -5265,7 +5218,7 @@ msgid "Add Article" msgstr "" #: ../../addon/wiki/Mod_Wiki.php:36 -#: ../../addon/flashcards/Mod_Flashcards.php:52 +#: ../../addon/flashcards/Mod_Flashcards.php:58 #: ../../addon/faces/Mod_Faces.php:64 ../../addon/cart/cart.php:1458 msgid "Profile Unavailable." msgstr "" @@ -5273,7 +5226,7 @@ msgstr "" #: ../../addon/wiki/Mod_Wiki.php:81 ../../addon/cart/manual_payments.php:93 #: ../../addon/cart/submodules/paypalbuttonV2.php:486 #: ../../addon/cart/submodules/paypalbutton.php:456 -#: ../../addon/cart/myshop.php:37 ../../addon/cart/cart.php:1609 +#: ../../addon/cart/myshop.php:37 ../../addon/cart/cart.php:1608 msgid "Invalid channel" msgstr "" @@ -5290,11 +5243,11 @@ msgid "Error downloading wiki: " msgstr "" #: ../../addon/wiki/Mod_Wiki.php:209 ../../addon/wiki/Widget/Wiki_list.php:23 -#: ../../addon/wiki/wiki.php:45 ../../addon/wiki/wiki.php:98 +#: ../../addon/wiki/wiki.php:45 ../../addon/wiki/wiki.php:99 msgid "Wikis" msgstr "" -#: ../../addon/wiki/Mod_Wiki.php:215 ../../Zotlabs/Storage/Browser.php:407 +#: ../../addon/wiki/Mod_Wiki.php:215 ../../Zotlabs/Storage/Browser.php:411 msgid "Download" msgstr "" @@ -5317,7 +5270,7 @@ msgstr "" msgid "Content type" msgstr "" -#: ../../addon/wiki/Mod_Wiki.php:222 ../../Zotlabs/Storage/Browser.php:382 +#: ../../addon/wiki/Mod_Wiki.php:222 ../../Zotlabs/Storage/Browser.php:386 msgid "Type" msgstr "" @@ -5345,6 +5298,13 @@ msgstr "" msgid "Rename page" msgstr "" +#: ../../addon/wiki/Mod_Wiki.php:304 ../../addon/hsse/hsse.php:186 +#: ../../Zotlabs/Lib/ThreadItem.php:294 ../../Zotlabs/Widget/Cdav.php:142 +#: ../../Zotlabs/Module/Webpages.php:250 ../../Zotlabs/Module/Layouts.php:192 +#: ../../Zotlabs/Module/Blocks.php:159 ../../Zotlabs/Module/Photos.php:1077 +msgid "Share" +msgstr "" + #: ../../addon/wiki/Mod_Wiki.php:318 msgid "Error retrieving page content" msgstr "" @@ -5803,23 +5763,10 @@ msgstr "" msgid "GNU-Social Crosspost Connector" msgstr "" -#: ../../addon/flashcards/Mod_Flashcards.php:225 -msgid "Not allowed." -msgstr "" - -#: ../../addon/flashcards/Mod_Flashcards.php:268 -#: ../../Zotlabs/Module/Filestorage.php:202 -msgid "Set/edit permissions" -msgstr "" - -#: ../../addon/flashcards/Mod_Flashcards.php:291 -#: ../../addon/flashcards/Mod_Flashcards.php:292 -#: ../../Zotlabs/Module/Display.php:59 ../../Zotlabs/Module/Display.php:120 -#: ../../Zotlabs/Module/Display.php:396 ../../Zotlabs/Module/Thing.php:120 -#: ../../Zotlabs/Module/Filestorage.php:29 ../../Zotlabs/Module/Viewsrc.php:25 -#: ../../Zotlabs/Module/Admin/Themes.php:73 -#: ../../Zotlabs/Module/Admin/Addons.php:42 ../../Zotlabs/Module/Admin.php:63 -msgid "Item not found." +#: ../../addon/flashcards/Mod_Flashcards.php:161 +#: ../../Zotlabs/Module/Contactedit.php:431 +#: ../../Zotlabs/Module/Connedit.php:572 +msgid "Affinity" msgstr "" #: ../../addon/ljpost/ljpost.php:49 @@ -5861,7 +5808,7 @@ msgstr "" #: ../../addon/cart/manual_payments.php:68 #: ../../addon/cart/submodules/paypalbuttonV2.php:417 #: ../../addon/cart/submodules/paypalbutton.php:392 -#: ../../addon/cart/cart.php:1631 +#: ../../addon/cart/cart.php:1630 msgid "Order not found." msgstr "" @@ -6099,35 +6046,35 @@ msgstr "" msgid "Shop" msgstr "" -#: ../../addon/cart/cart.php:1598 +#: ../../addon/cart/cart.php:1597 msgid "You must be logged into the Grid to shop." msgstr "" -#: ../../addon/cart/cart.php:1647 +#: ../../addon/cart/cart.php:1646 msgid "Access denied." msgstr "" -#: ../../addon/cart/cart.php:1699 ../../addon/cart/cart.php:1842 +#: ../../addon/cart/cart.php:1698 ../../addon/cart/cart.php:1841 msgid "No Order Found" msgstr "" -#: ../../addon/cart/cart.php:1708 +#: ../../addon/cart/cart.php:1707 msgid "An unknown error has occurred Please start again." msgstr "" -#: ../../addon/cart/cart.php:1851 +#: ../../addon/cart/cart.php:1850 msgid "Requirements not met." msgstr "" -#: ../../addon/cart/cart.php:1851 +#: ../../addon/cart/cart.php:1850 msgid "Review your order and complete any needed requirements." msgstr "" -#: ../../addon/cart/cart.php:1877 +#: ../../addon/cart/cart.php:1876 msgid "Invalid Payment Type. Please start again." msgstr "" -#: ../../addon/cart/cart.php:1884 +#: ../../addon/cart/cart.php:1883 msgid "Order not found" msgstr "" @@ -6629,45 +6576,45 @@ msgstr "" msgid "I won!" msgstr "" -#: ../../boot.php:1730 +#: ../../boot.php:1737 msgid "Create an account to access services and applications" msgstr "" -#: ../../boot.php:1748 +#: ../../boot.php:1755 msgid "Email or nickname" msgstr "" -#: ../../boot.php:1758 +#: ../../boot.php:1765 msgid "Password" msgstr "" -#: ../../boot.php:1759 +#: ../../boot.php:1766 msgid "Remember me" msgstr "" -#: ../../boot.php:1762 +#: ../../boot.php:1769 msgid "Forgot your password?" msgstr "" -#: ../../boot.php:1763 ../../Zotlabs/Module/Lostpass.php:91 +#: ../../boot.php:1770 ../../Zotlabs/Module/Lostpass.php:91 msgid "Password Reset" msgstr "" -#: ../../boot.php:2641 +#: ../../boot.php:2551 #, php-format msgid "[$Projectname] Website SSL error for %s" msgstr "" -#: ../../boot.php:2646 +#: ../../boot.php:2556 msgid "Website SSL certificate is not valid. Please correct." msgstr "" -#: ../../boot.php:2762 +#: ../../boot.php:2674 #, php-format msgid "[$Projectname] Cron tasks not running on %s" msgstr "" -#: ../../boot.php:2767 +#: ../../boot.php:2679 msgid "Cron/Scheduled tasks not running." msgstr "" @@ -6713,7 +6660,7 @@ msgstr "" #: ../../Zotlabs/Lib/Enotify.php:134 #, php-format -msgid "%1$s sent you a new direct message at %2$s" +msgid "%1$s sent you a new private message at %2$s" msgstr "" #: ../../Zotlabs/Lib/Enotify.php:135 @@ -6727,34 +6674,38 @@ msgstr "" #: ../../Zotlabs/Lib/Enotify.php:136 #, php-format -msgid "Please visit %s to view and/or reply to your direct messages." +msgid "Please visit %s to view and/or reply to your private messages." msgstr "" #: ../../Zotlabs/Lib/Enotify.php:149 -msgid "requested to comment on" +msgid "requested to post in" msgstr "" #: ../../Zotlabs/Lib/Enotify.php:149 -msgid "commented on" +msgid "posted in" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:162 ../../Zotlabs/Lib/Enotify.php:318 +#: ../../Zotlabs/Lib/Enotify.php:162 ../../Zotlabs/Lib/Enotify.php:325 msgid "requested to like" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:162 ../../Zotlabs/Lib/Enotify.php:318 +#: ../../Zotlabs/Lib/Enotify.php:162 ../../Zotlabs/Lib/Enotify.php:325 msgid "liked" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:165 ../../Zotlabs/Lib/Enotify.php:321 +#: ../../Zotlabs/Lib/Enotify.php:165 ../../Zotlabs/Lib/Enotify.php:328 msgid "requested to dislike" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:165 ../../Zotlabs/Lib/Enotify.php:321 +#: ../../Zotlabs/Lib/Enotify.php:165 ../../Zotlabs/Lib/Enotify.php:328 msgid "disliked" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:168 +#: ../../Zotlabs/Lib/Enotify.php:168 ../../Zotlabs/Lib/Enotify.php:331 +msgid "requested to repeat" +msgstr "" + +#: ../../Zotlabs/Lib/Enotify.php:168 ../../Zotlabs/Lib/Enotify.php:331 msgid "repeated" msgstr "" @@ -6762,226 +6713,221 @@ msgstr "" msgid "voted on" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:216 +#: ../../Zotlabs/Lib/Enotify.php:217 #, php-format msgid "%1$s %2$s [zrl=%3$s]a %4$s[/zrl]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:224 +#: ../../Zotlabs/Lib/Enotify.php:227 #, php-format msgid "%1$s %2$s [zrl=%3$s]%4$s's %5$s[/zrl]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:233 ../../Zotlabs/Lib/Enotify.php:325 +#: ../../Zotlabs/Lib/Enotify.php:239 ../../Zotlabs/Lib/Enotify.php:335 #, php-format msgid "%1$s %2$s [zrl=%3$s]your %4$s[/zrl]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:245 +#: ../../Zotlabs/Lib/Enotify.php:253 #, php-format msgid "[$Projectname:Notify] Moderated Comment to conversation #%1$d by %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:247 +#: ../../Zotlabs/Lib/Enotify.php:255 #, php-format msgid "[$Projectname:Notify] Comment to conversation #%1$d by %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:248 +#: ../../Zotlabs/Lib/Enotify.php:256 #, php-format msgid "%1$s commented on an item/conversation you have been following" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:251 ../../Zotlabs/Lib/Enotify.php:345 -#: ../../Zotlabs/Lib/Enotify.php:361 ../../Zotlabs/Lib/Enotify.php:385 -#: ../../Zotlabs/Lib/Enotify.php:402 ../../Zotlabs/Lib/Enotify.php:416 +#: ../../Zotlabs/Lib/Enotify.php:259 ../../Zotlabs/Lib/Enotify.php:356 +#: ../../Zotlabs/Lib/Enotify.php:372 ../../Zotlabs/Lib/Enotify.php:396 +#: ../../Zotlabs/Lib/Enotify.php:413 ../../Zotlabs/Lib/Enotify.php:427 #, php-format msgid "Please visit %s to view and/or reply to the conversation." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:255 ../../Zotlabs/Lib/Enotify.php:256 +#: ../../Zotlabs/Lib/Enotify.php:263 ../../Zotlabs/Lib/Enotify.php:264 #, php-format msgid "Please visit %s to approve or reject this comment." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:341 +#: ../../Zotlabs/Lib/Enotify.php:352 #, php-format msgid "[$Projectname:Notify] Like received to conversation #%1$d by %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:342 +#: ../../Zotlabs/Lib/Enotify.php:353 #, php-format msgid "%1$s liked an item/conversation you created" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:353 +#: ../../Zotlabs/Lib/Enotify.php:364 #, php-format msgid "[$Projectname:Notify] %s posted to your profile wall" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:355 +#: ../../Zotlabs/Lib/Enotify.php:366 #, php-format msgid "%1$s posted to your profile wall at %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:357 +#: ../../Zotlabs/Lib/Enotify.php:368 #, php-format msgid "%1$s posted to [zrl=%2$s]your wall[/zrl]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:379 +#: ../../Zotlabs/Lib/Enotify.php:390 #, php-format msgid "[$Projectname:Notify] %s tagged you" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:380 +#: ../../Zotlabs/Lib/Enotify.php:391 #, php-format msgid "%1$s tagged you at %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:381 +#: ../../Zotlabs/Lib/Enotify.php:392 #, php-format msgid "%1$s [zrl=%2$s]tagged you[/zrl]." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:392 +#: ../../Zotlabs/Lib/Enotify.php:403 #, php-format msgid "[$Projectname:Notify] %1$s poked you" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:393 +#: ../../Zotlabs/Lib/Enotify.php:404 #, php-format msgid "%1$s poked you at %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:394 +#: ../../Zotlabs/Lib/Enotify.php:405 #, php-format msgid "%1$s [zrl=%2$s]poked you[/zrl]." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:410 +#: ../../Zotlabs/Lib/Enotify.php:421 #, php-format msgid "[$Projectname:Notify] %s tagged your post" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:411 +#: ../../Zotlabs/Lib/Enotify.php:422 #, php-format msgid "%1$s tagged your post at %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:412 +#: ../../Zotlabs/Lib/Enotify.php:423 #, php-format msgid "%1$s tagged [zrl=%2$s]your post[/zrl]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:422 +#: ../../Zotlabs/Lib/Enotify.php:433 msgid "[$Projectname:Notify] Introduction received" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:423 +#: ../../Zotlabs/Lib/Enotify.php:434 #, php-format msgid "You've received an new connection request from '%1$s' at %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:424 +#: ../../Zotlabs/Lib/Enotify.php:435 #, php-format msgid "You've received [zrl=%1$s]a new connection request[/zrl] from %2$s." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:427 ../../Zotlabs/Lib/Enotify.php:446 +#: ../../Zotlabs/Lib/Enotify.php:438 ../../Zotlabs/Lib/Enotify.php:457 #, php-format msgid "You may visit their profile at %s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:429 +#: ../../Zotlabs/Lib/Enotify.php:440 #, php-format msgid "Please visit %s to approve or reject the connection request." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:437 +#: ../../Zotlabs/Lib/Enotify.php:448 msgid "[$Projectname:Notify] Friend suggestion received" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:438 +#: ../../Zotlabs/Lib/Enotify.php:449 #, php-format msgid "You've received a friend suggestion from '%1$s' at %2$s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:439 +#: ../../Zotlabs/Lib/Enotify.php:450 #, php-format msgid "You've received [zrl=%1$s]a friend suggestion[/zrl] for %2$s from %3$s." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:444 +#: ../../Zotlabs/Lib/Enotify.php:455 msgid "Name:" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:445 +#: ../../Zotlabs/Lib/Enotify.php:456 msgid "Photo:" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:448 +#: ../../Zotlabs/Lib/Enotify.php:459 #, php-format msgid "Please visit %s to approve or reject the suggestion." msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:677 +#: ../../Zotlabs/Lib/Enotify.php:694 msgid "[$Projectname:Notify]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:843 -msgid "created a new poll" +#: ../../Zotlabs/Lib/Enotify.php:860 +msgid "started a poll" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:843 -msgid "created a new post" +#: ../../Zotlabs/Lib/Enotify.php:860 +msgid "started a conversation" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:844 +#: ../../Zotlabs/Lib/Enotify.php:861 #, php-format msgid "voted on %s's poll" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:844 +#: ../../Zotlabs/Lib/Enotify.php:861 #, php-format -msgid "commented on %s's post" +msgid "posted in %s's conversation" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:848 ../../Zotlabs/Lib/Enotify.php:948 +#: ../../Zotlabs/Lib/Enotify.php:865 ../../Zotlabs/Lib/Enotify.php:957 msgid "shared a file with you" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:857 +#: ../../Zotlabs/Lib/Enotify.php:873 #, php-format -msgid "edited a post dated %s" +msgid "edited a message dated %s" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:860 -#, php-format -msgid "edited a comment dated %s" -msgstr "" - -#: ../../Zotlabs/Lib/Enotify.php:933 +#: ../../Zotlabs/Lib/Enotify.php:942 msgid "added your channel" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:963 +#: ../../Zotlabs/Lib/Enotify.php:972 msgid "sent you a direct message" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:970 +#: ../../Zotlabs/Lib/Enotify.php:979 msgid "g A l F d" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:973 +#: ../../Zotlabs/Lib/Enotify.php:982 msgid "[today]" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:983 +#: ../../Zotlabs/Lib/Enotify.php:992 msgid "created an event" msgstr "" -#: ../../Zotlabs/Lib/Enotify.php:998 +#: ../../Zotlabs/Lib/Enotify.php:1007 msgid "status verified" msgstr "" @@ -7009,10 +6955,6 @@ msgstr "" msgid "Channel Manager" msgstr "" -#: ../../Zotlabs/Lib/Apps.php:344 -msgid "Stream" -msgstr "" - #: ../../Zotlabs/Lib/Apps.php:348 msgid "Wiki" msgstr "" @@ -7045,11 +6987,12 @@ msgstr "" msgid "Features" msgstr "" -#: ../../Zotlabs/Lib/Apps.php:364 ../../Zotlabs/Storage/Browser.php:410 +#: ../../Zotlabs/Lib/Apps.php:364 ../../Zotlabs/Storage/Browser.php:414 msgid "Post" msgstr "" -#: ../../Zotlabs/Lib/Apps.php:369 +#: ../../Zotlabs/Lib/Apps.php:369 ../../Zotlabs/Widget/Notifications.php:116 +#: ../../Zotlabs/Widget/Messages.php:51 msgid "Notifications" msgstr "" @@ -7206,216 +7149,225 @@ msgstr "" msgid "Update %s failed. See error logs." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:45 ../../Zotlabs/Lib/Connect.php:146 +#: ../../Zotlabs/Lib/Connect.php:51 ../../Zotlabs/Lib/Connect.php:152 msgid "Channel is blocked on this site." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:50 +#: ../../Zotlabs/Lib/Connect.php:56 msgid "Channel location missing." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:104 +#: ../../Zotlabs/Lib/Connect.php:110 msgid "Remote channel or protocol unavailable." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:140 +#: ../../Zotlabs/Lib/Connect.php:146 msgid "Channel discovery failed." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:158 +#: ../../Zotlabs/Lib/Connect.php:164 msgid "Protocol disabled." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:170 +#: ../../Zotlabs/Lib/Connect.php:176 msgid "Cannot connect to yourself." msgstr "" -#: ../../Zotlabs/Lib/Connect.php:275 +#: ../../Zotlabs/Lib/Connect.php:281 msgid "error saving data" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:110 +#: ../../Zotlabs/Lib/ThreadItem.php:107 msgid "Restricted message" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:117 -msgid "Direct message" +#: ../../Zotlabs/Lib/ThreadItem.php:114 +msgid "Private message" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:122 +#: ../../Zotlabs/Lib/ThreadItem.php:119 msgid "Public Policy" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:156 +#: ../../Zotlabs/Lib/ThreadItem.php:153 msgid "Privacy conflict. Discretion advised." msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:187 ../../Zotlabs/Storage/Browser.php:373 +#: ../../Zotlabs/Lib/ThreadItem.php:184 ../../Zotlabs/Storage/Browser.php:377 msgid "Admin Delete" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:190 ../../Zotlabs/Module/Filer.php:66 +#: ../../Zotlabs/Lib/ThreadItem.php:187 ../../Zotlabs/Module/Filer.php:66 msgid "Save to Folder" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:217 ../../Zotlabs/Widget/Pinned.php:77 +#: ../../Zotlabs/Lib/ThreadItem.php:214 msgid "I will attend" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:217 ../../Zotlabs/Widget/Pinned.php:77 +#: ../../Zotlabs/Lib/ThreadItem.php:214 msgid "I will not attend" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:217 ../../Zotlabs/Widget/Pinned.php:77 +#: ../../Zotlabs/Lib/ThreadItem.php:214 msgid "I might attend" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:296 ../../Zotlabs/Module/Photos.php:1074 -msgid "I like this (toggle)" -msgstr "" - -#: ../../Zotlabs/Lib/ThreadItem.php:297 ../../Zotlabs/Module/Photos.php:1075 -msgid "I don't like this (toggle)" -msgstr "" - -#: ../../Zotlabs/Lib/ThreadItem.php:298 -msgid "Reply to this comment" +#: ../../Zotlabs/Lib/ThreadItem.php:287 +msgid "Reply to this message" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:298 +#: ../../Zotlabs/Lib/ThreadItem.php:287 msgid "reply" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:298 +#: ../../Zotlabs/Lib/ThreadItem.php:287 msgid "Reply to" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:305 ../../Zotlabs/Widget/Pinned.php:95 +#: ../../Zotlabs/Lib/ThreadItem.php:294 ../../Zotlabs/Widget/Pinned.php:95 msgid "share" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:309 +#: ../../Zotlabs/Lib/ThreadItem.php:298 msgid "Repeat" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:309 +#: ../../Zotlabs/Lib/ThreadItem.php:298 msgid "repeat" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:320 +#: ../../Zotlabs/Lib/ThreadItem.php:309 msgid "Delivery Report" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:341 +#: ../../Zotlabs/Lib/ThreadItem.php:330 #, php-format msgid "%d comment" msgid_plural "%d comments" msgstr[0] "" msgstr[1] "" -#: ../../Zotlabs/Lib/ThreadItem.php:342 +#: ../../Zotlabs/Lib/ThreadItem.php:332 #, php-format msgid "%d unseen" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:391 +#: ../../Zotlabs/Lib/ThreadItem.php:363 +#, php-format +msgid "Load the next few of total %d comments" +msgstr "" + +#: ../../Zotlabs/Lib/ThreadItem.php:369 +msgid "Expand Replies" +msgstr "" + +#: ../../Zotlabs/Lib/ThreadItem.php:388 msgid "Forum" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:398 +#: ../../Zotlabs/Lib/ThreadItem.php:395 msgid "to" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:399 ../../Zotlabs/Widget/Messages.php:175 -#: ../../Zotlabs/Widget/Messages.php:178 ../../Zotlabs/Widget/Pinned.php:122 +#: ../../Zotlabs/Lib/ThreadItem.php:396 ../../Zotlabs/Widget/Messages.php:179 +#: ../../Zotlabs/Widget/Messages.php:182 ../../Zotlabs/Widget/Pinned.php:125 msgid "via" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:400 +#: ../../Zotlabs/Lib/ThreadItem.php:397 msgid "Wall-to-Wall" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:401 +#: ../../Zotlabs/Lib/ThreadItem.php:398 msgid "via Wall-To-Wall:" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:417 +#: ../../Zotlabs/Lib/ThreadItem.php:414 #, php-format msgid "Last edited %s" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:418 +#: ../../Zotlabs/Lib/ThreadItem.php:415 #, php-format msgid "Expires %s" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:421 +#: ../../Zotlabs/Lib/ThreadItem.php:418 #, php-format msgid "Published %s" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:428 +#: ../../Zotlabs/Lib/ThreadItem.php:425 msgid "Attend" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:429 ../../Zotlabs/Widget/Pinned.php:136 +#: ../../Zotlabs/Lib/ThreadItem.php:426 ../../Zotlabs/Widget/Pinned.php:139 msgid "Attendance Options" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:431 ../../Zotlabs/Widget/Pinned.php:137 +#: ../../Zotlabs/Lib/ThreadItem.php:428 ../../Zotlabs/Widget/Pinned.php:140 msgid "Voting Options" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:446 +#: ../../Zotlabs/Lib/ThreadItem.php:442 msgid "Go to previous comment" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:455 ../../Zotlabs/Widget/Pinned.php:149 +#: ../../Zotlabs/Lib/ThreadItem.php:452 ../../Zotlabs/Widget/Pinned.php:152 msgid "Pinned post" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:459 +#: ../../Zotlabs/Lib/ThreadItem.php:456 msgid "Add to Calendar" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:467 +#: ../../Zotlabs/Lib/ThreadItem.php:464 msgid "Mark all comments seen" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:485 +#: ../../Zotlabs/Lib/ThreadItem.php:483 msgid "Add yours" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:485 +#: ../../Zotlabs/Lib/ThreadItem.php:483 msgid "Remove yours" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:796 ../../Zotlabs/Module/Photos.php:1092 -#: ../../Zotlabs/Module/Photos.php:1205 -msgid "This is you" +#: ../../Zotlabs/Lib/ThreadItem.php:496 +msgid "show less" +msgstr "" + +#: ../../Zotlabs/Lib/ThreadItem.php:497 +msgid "show more" +msgstr "" + +#: ../../Zotlabs/Lib/ThreadItem.php:497 +msgid "show all" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:806 -msgid "Image" +#: ../../Zotlabs/Lib/ThreadItem.php:806 ../../Zotlabs/Module/Photos.php:1093 +#: ../../Zotlabs/Module/Photos.php:1194 +msgid "This is you" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:808 +#: ../../Zotlabs/Lib/ThreadItem.php:818 msgid "Insert Link" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:809 +#: ../../Zotlabs/Lib/ThreadItem.php:819 msgid "Video" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:818 +#: ../../Zotlabs/Lib/ThreadItem.php:828 msgid "Your full name (required)" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:819 +#: ../../Zotlabs/Lib/ThreadItem.php:829 msgid "Your email address (required)" msgstr "" -#: ../../Zotlabs/Lib/ThreadItem.php:820 +#: ../../Zotlabs/Lib/ThreadItem.php:830 msgid "Your website URL (optional)" msgstr "" @@ -7423,32 +7375,32 @@ msgstr "" msgid "Unable to verify channel signature" msgstr "" -#: ../../Zotlabs/Lib/Activity.php:2259 +#: ../../Zotlabs/Lib/Activity.php:2202 #, php-format msgid "Likes %1$s's %2$s" msgstr "" -#: ../../Zotlabs/Lib/Activity.php:2262 +#: ../../Zotlabs/Lib/Activity.php:2205 #, php-format msgid "Doesn't like %1$s's %2$s" msgstr "" -#: ../../Zotlabs/Lib/Activity.php:2268 +#: ../../Zotlabs/Lib/Activity.php:2211 #, php-format msgid "Will attend %s's event" msgstr "" -#: ../../Zotlabs/Lib/Activity.php:2271 +#: ../../Zotlabs/Lib/Activity.php:2214 #, php-format msgid "Will not attend %s's event" msgstr "" -#: ../../Zotlabs/Lib/Activity.php:2274 +#: ../../Zotlabs/Lib/Activity.php:2217 #, php-format msgid "May attend %s's event" msgstr "" -#: ../../Zotlabs/Lib/Activity.php:2277 +#: ../../Zotlabs/Lib/Activity.php:2220 #, php-format msgid "May not attend %s's event" msgstr "" @@ -7707,7 +7659,7 @@ msgid "View Ratings" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:24 -msgid "New network activity notifications" +msgid "Unseen network activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:27 @@ -7716,14 +7668,14 @@ msgstr "" #: ../../Zotlabs/Widget/Notifications.php:30 #: ../../Zotlabs/Widget/Notifications.php:69 -msgid "Mark all notifications read" +msgid "Mark all read" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:33 #: ../../Zotlabs/Widget/Notifications.php:53 #: ../../Zotlabs/Widget/Notifications.php:72 #: ../../Zotlabs/Widget/Notifications.php:166 -msgid "Show new posts only" +msgid "Conversation starters" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:34 @@ -7731,33 +7683,36 @@ msgstr "" #: ../../Zotlabs/Widget/Notifications.php:73 #: ../../Zotlabs/Widget/Notifications.php:134 #: ../../Zotlabs/Widget/Notifications.php:167 -#: ../../Zotlabs/Widget/Messages.php:53 +#: ../../Zotlabs/Widget/Messages.php:55 msgid "Filter by name or address" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:44 -msgid "New home activity notifications" +#: ../../Zotlabs/Module/Settings/Channel.php:259 +msgid "Unseen channel activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:47 -msgid "Home stream" +msgid "Channel stream" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:50 -msgid "Mark all notifications seen" +#: ../../Zotlabs/Widget/Notifications.php:88 +#: ../../Zotlabs/Widget/Notifications.php:123 +#: ../../Zotlabs/Module/Notifications.php:111 +msgid "Mark all seen" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:62 -#: ../../Zotlabs/Widget/Activity_filter.php:44 -msgid "Direct Messages" +msgid "Private" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:63 -msgid "New direct messages notifications" +msgid "Unseen private activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:66 -msgid "Direct messages stream" +msgid "Private stream" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:81 @@ -7766,46 +7721,39 @@ msgid "Events" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:82 -msgid "New events notifications" +msgid "Unseen events activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:85 msgid "View events" msgstr "" -#: ../../Zotlabs/Widget/Notifications.php:88 -msgid "Mark all events seen" -msgstr "" - #: ../../Zotlabs/Widget/Notifications.php:96 #: ../../Zotlabs/Module/Connections.php:168 msgid "New Connections" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:97 -msgid "New connections notifications" +#: ../../Zotlabs/Module/Settings/Channel.php:267 +msgid "New connections" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:100 -msgid "View all connections" +#: ../../Zotlabs/Widget/Notifications.php:120 +#: ../../Zotlabs/Module/Photos.php:1114 ../../Zotlabs/Module/Photos.php:1126 +msgid "View all" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:109 -msgid "New files notifications" +msgid "Useen files activity" msgstr "" -#: ../../Zotlabs/Widget/Notifications.php:116 #: ../../Zotlabs/Widget/Notifications.php:117 -#: ../../Zotlabs/Widget/Messages.php:49 -msgid "Notices" +msgid "Unseen notifications" msgstr "" -#: ../../Zotlabs/Widget/Notifications.php:120 -msgid "View all notices" -msgstr "" - -#: ../../Zotlabs/Widget/Notifications.php:123 -msgid "Mark all notices seen" +#: ../../Zotlabs/Widget/Notifications.php:132 +msgid "Unseen forums activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:144 @@ -7813,11 +7761,12 @@ msgid "Registrations" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:145 -msgid "New registrations notifications" +msgid "Unseen registration activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:155 -msgid "New public stream notifications" +#: ../../Zotlabs/Module/Settings/Channel.php:270 +msgid "Unseen public stream activity" msgstr "" #: ../../Zotlabs/Widget/Notifications.php:158 @@ -7905,7 +7854,7 @@ msgid "View public stream" msgstr "" #: ../../Zotlabs/Widget/Newmember.php:82 -#: ../../Zotlabs/Module/Settings/Display.php:202 +#: ../../Zotlabs/Module/Settings/Display.php:201 msgid "New Member Links" msgstr "" @@ -7921,31 +7870,31 @@ msgstr "" msgid "See more..." msgstr "" -#: ../../Zotlabs/Widget/Messages.php:45 -msgid "Public and restricted messages" +#: ../../Zotlabs/Widget/Messages.php:47 +msgid "Public and restricted conversations" msgstr "" -#: ../../Zotlabs/Widget/Messages.php:46 -msgid "Direct messages" +#: ../../Zotlabs/Widget/Messages.php:48 +msgid "Private conversations" msgstr "" -#: ../../Zotlabs/Widget/Messages.php:47 -msgid "Starred messages" +#: ../../Zotlabs/Widget/Messages.php:49 +msgid "Starred conversations" msgstr "" -#: ../../Zotlabs/Widget/Messages.php:48 +#: ../../Zotlabs/Widget/Messages.php:50 msgid "Filed messages" msgstr "" -#: ../../Zotlabs/Widget/Messages.php:51 -msgid "No messages" +#: ../../Zotlabs/Widget/Messages.php:53 +msgid "No conversations" msgstr "" -#: ../../Zotlabs/Widget/Messages.php:52 -msgid "Unseen" +#: ../../Zotlabs/Widget/Messages.php:54 +msgid "Unseen reactions" msgstr "" -#: ../../Zotlabs/Widget/Messages.php:54 +#: ../../Zotlabs/Widget/Messages.php:56 msgid "Filter by file name" msgstr "" @@ -7961,24 +7910,24 @@ msgstr "" msgid "Channel activities" msgstr "" -#: ../../Zotlabs/Widget/Album.php:84 ../../Zotlabs/Widget/Portfolio.php:91 -#: ../../Zotlabs/Module/Embedphotos.php:171 ../../Zotlabs/Module/Photos.php:782 -#: ../../Zotlabs/Module/Photos.php:1324 +#: ../../Zotlabs/Widget/Album.php:87 ../../Zotlabs/Widget/Portfolio.php:95 +#: ../../Zotlabs/Module/Embedphotos.php:173 ../../Zotlabs/Module/Photos.php:784 +#: ../../Zotlabs/Module/Photos.php:1318 msgid "View Photo" msgstr "" -#: ../../Zotlabs/Widget/Album.php:101 ../../Zotlabs/Widget/Portfolio.php:112 -#: ../../Zotlabs/Module/Embedphotos.php:187 ../../Zotlabs/Module/Photos.php:813 +#: ../../Zotlabs/Widget/Album.php:104 ../../Zotlabs/Widget/Portfolio.php:116 +#: ../../Zotlabs/Module/Embedphotos.php:189 ../../Zotlabs/Module/Photos.php:815 msgid "Edit Album" msgstr "" -#: ../../Zotlabs/Widget/Album.php:103 ../../Zotlabs/Widget/Portfolio.php:114 +#: ../../Zotlabs/Widget/Album.php:106 ../../Zotlabs/Widget/Portfolio.php:118 #: ../../Zotlabs/Widget/Cdav.php:152 ../../Zotlabs/Widget/Cdav.php:188 -#: ../../Zotlabs/Storage/Browser.php:546 +#: ../../Zotlabs/Storage/Browser.php:550 #: ../../Zotlabs/Module/Cover_photo.php:381 -#: ../../Zotlabs/Module/Embedphotos.php:189 +#: ../../Zotlabs/Module/Embedphotos.php:191 #: ../../Zotlabs/Module/Profile_photo.php:547 -#: ../../Zotlabs/Module/Photos.php:681 +#: ../../Zotlabs/Module/Photos.php:683 msgid "Upload" msgstr "" @@ -7986,12 +7935,12 @@ msgstr "" msgid "Share This" msgstr "" -#: ../../Zotlabs/Widget/Pinned.php:117 ../../Zotlabs/Widget/Pinned.php:118 +#: ../../Zotlabs/Widget/Pinned.php:120 ../../Zotlabs/Widget/Pinned.php:121 #, php-format msgid "View %s's profile - %s" msgstr "" -#: ../../Zotlabs/Widget/Pinned.php:151 +#: ../../Zotlabs/Widget/Pinned.php:154 msgid "Don't show" msgstr "" @@ -8032,20 +7981,20 @@ msgstr "" msgid "Saved" msgstr "" -#: ../../Zotlabs/Widget/Activity_order.php:96 -msgid "Commented Date" +#: ../../Zotlabs/Widget/Activity_order.php:94 +msgid "Posted Date" msgstr "" -#: ../../Zotlabs/Widget/Activity_order.php:100 -msgid "Order by last commented date" +#: ../../Zotlabs/Widget/Activity_order.php:98 +msgid "Order by last posted date" msgstr "" -#: ../../Zotlabs/Widget/Activity_order.php:103 -msgid "Posted Date" +#: ../../Zotlabs/Widget/Activity_order.php:102 +msgid "Commented Date" msgstr "" -#: ../../Zotlabs/Widget/Activity_order.php:107 -msgid "Order by last posted date" +#: ../../Zotlabs/Widget/Activity_order.php:106 +msgid "Order by last commented date" msgstr "" #: ../../Zotlabs/Widget/Activity_order.php:110 @@ -8060,6 +8009,10 @@ msgstr "" msgid "Stream Order" msgstr "" +#: ../../Zotlabs/Widget/Activity_filter.php:44 +msgid "Direct Messages" +msgstr "" + #: ../../Zotlabs/Widget/Activity_filter.php:48 msgid "Show direct (private) messages" msgstr "" @@ -8343,7 +8296,7 @@ msgid "Create new CalDAV calendar" msgstr "" #: ../../Zotlabs/Widget/Cdav.php:146 ../../Zotlabs/Widget/Cdav.php:184 -#: ../../Zotlabs/Storage/Browser.php:368 ../../Zotlabs/Storage/Browser.php:544 +#: ../../Zotlabs/Storage/Browser.php:372 ../../Zotlabs/Storage/Browser.php:548 #: ../../Zotlabs/Module/Webpages.php:248 ../../Zotlabs/Module/Connedit.php:747 #: ../../Zotlabs/Module/Layouts.php:183 ../../Zotlabs/Module/Menu.php:182 #: ../../Zotlabs/Module/Blocks.php:157 ../../Zotlabs/Module/New_channel.php:190 @@ -8408,129 +8361,129 @@ msgstr "" msgid "Privacy groups" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:292 +#: ../../Zotlabs/Storage/Browser.php:296 msgid "Change filename to" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:309 ../../Zotlabs/Storage/Browser.php:394 +#: ../../Zotlabs/Storage/Browser.php:313 ../../Zotlabs/Storage/Browser.php:398 msgid "Select a target location" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:310 ../../Zotlabs/Storage/Browser.php:395 +#: ../../Zotlabs/Storage/Browser.php:314 ../../Zotlabs/Storage/Browser.php:399 msgid "Copy to target location" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:311 ../../Zotlabs/Storage/Browser.php:393 +#: ../../Zotlabs/Storage/Browser.php:315 ../../Zotlabs/Storage/Browser.php:397 msgid "Set permissions for all files and sub folders" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:312 +#: ../../Zotlabs/Storage/Browser.php:316 msgid "Notify your contacts about this file" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:351 +#: ../../Zotlabs/Storage/Browser.php:355 msgid "File category" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:365 +#: ../../Zotlabs/Storage/Browser.php:369 msgid "Total" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:367 +#: ../../Zotlabs/Storage/Browser.php:371 msgid "Shared" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:369 +#: ../../Zotlabs/Storage/Browser.php:373 msgid "Add Files" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:384 +#: ../../Zotlabs/Storage/Browser.php:388 #: ../../Zotlabs/Module/Sharedwithme.php:110 msgid "Last Modified" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:385 +#: ../../Zotlabs/Storage/Browser.php:389 msgid "parent" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:390 +#: ../../Zotlabs/Storage/Browser.php:394 #: ../../Zotlabs/Module/Filestorage.php:206 msgid "Copy/paste this code to attach file to a post" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:391 +#: ../../Zotlabs/Storage/Browser.php:395 #: ../../Zotlabs/Module/Filestorage.php:207 msgid "Copy/paste this URL to link file from a web page" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:402 +#: ../../Zotlabs/Storage/Browser.php:406 msgid "Select All" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:403 +#: ../../Zotlabs/Storage/Browser.php:407 msgid "Bulk Actions" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:404 +#: ../../Zotlabs/Storage/Browser.php:408 msgid "Adjust Permissions" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:405 +#: ../../Zotlabs/Storage/Browser.php:409 msgid "Move or Copy" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:408 +#: ../../Zotlabs/Storage/Browser.php:412 msgid "Info" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:409 +#: ../../Zotlabs/Storage/Browser.php:413 msgid "Rename" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:411 +#: ../../Zotlabs/Storage/Browser.php:415 msgid "Attachment BBcode" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:412 +#: ../../Zotlabs/Storage/Browser.php:416 msgid "Embed BBcode" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:413 +#: ../../Zotlabs/Storage/Browser.php:417 msgid "Link BBcode" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:486 +#: ../../Zotlabs/Storage/Browser.php:490 #, php-format msgid "You are using %1$s of your available file storage." msgstr "" -#: ../../Zotlabs/Storage/Browser.php:491 +#: ../../Zotlabs/Storage/Browser.php:495 #, php-format msgid "You are using %1$s of %2$s available file storage. (%3$s%)" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:502 +#: ../../Zotlabs/Storage/Browser.php:506 msgid "WARNING:" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:543 +#: ../../Zotlabs/Storage/Browser.php:547 msgid "Create new folder" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:545 +#: ../../Zotlabs/Storage/Browser.php:549 msgid "Upload file" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:557 +#: ../../Zotlabs/Storage/Browser.php:561 msgid "Drop files here to immediately upload" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:558 +#: ../../Zotlabs/Storage/Browser.php:562 #: ../../Zotlabs/Module/Filestorage.php:211 msgid "Show in your contacts shared folder" msgstr "" -#: ../../Zotlabs/Storage/Browser.php:560 +#: ../../Zotlabs/Storage/Browser.php:564 msgid "" "You can select files via the upload button or drop them right here or into " "an existing folder." @@ -8602,27 +8555,35 @@ msgstr "" msgid "Public access denied." msgstr "" -#: ../../Zotlabs/Module/Display.php:53 ../../Zotlabs/Module/Oep.php:82 +#: ../../Zotlabs/Module/Display.php:53 ../../Zotlabs/Module/Oep.php:83 #: ../../Zotlabs/Module/Pubstream.php:55 ../../Zotlabs/Module/Channel.php:195 msgid "Malformed message id." msgstr "" -#: ../../Zotlabs/Module/Display.php:95 ../../Zotlabs/Module/Network.php:213 -#: ../../Zotlabs/Module/Hq.php:99 ../../Zotlabs/Module/Pubstream.php:98 +#: ../../Zotlabs/Module/Display.php:59 ../../Zotlabs/Module/Display.php:120 +#: ../../Zotlabs/Module/Display.php:391 ../../Zotlabs/Module/Thing.php:120 +#: ../../Zotlabs/Module/Filestorage.php:29 ../../Zotlabs/Module/Viewsrc.php:25 +#: ../../Zotlabs/Module/Admin/Themes.php:73 +#: ../../Zotlabs/Module/Admin/Addons.php:42 ../../Zotlabs/Module/Admin.php:63 +msgid "Item not found." +msgstr "" + +#: ../../Zotlabs/Module/Display.php:95 ../../Zotlabs/Module/Network.php:215 +#: ../../Zotlabs/Module/Hq.php:101 ../../Zotlabs/Module/Pubstream.php:98 #: ../../Zotlabs/Module/Channel.php:279 ../../Zotlabs/Module/Rpost.php:111 msgid "Reset form" msgstr "" -#: ../../Zotlabs/Module/Display.php:320 ../../Zotlabs/Module/Channel.php:501 +#: ../../Zotlabs/Module/Display.php:315 ../../Zotlabs/Module/Channel.php:503 msgid "" "You must enable javascript for your browser to be able to view this content." msgstr "" -#: ../../Zotlabs/Module/Display.php:340 +#: ../../Zotlabs/Module/Display.php:335 msgid "Article" msgstr "" -#: ../../Zotlabs/Module/Display.php:389 +#: ../../Zotlabs/Module/Display.php:384 msgid "Item has been removed." msgstr "" @@ -8707,11 +8668,11 @@ msgstr "" msgid "Edit Webpage" msgstr "" -#: ../../Zotlabs/Module/Sse_bs.php:633 +#: ../../Zotlabs/Module/Sse_bs.php:657 msgid "Private forum" msgstr "" -#: ../../Zotlabs/Module/Sse_bs.php:633 +#: ../../Zotlabs/Module/Sse_bs.php:657 msgid "Public forum" msgstr "" @@ -8847,23 +8808,23 @@ msgstr "" msgid "Remove authorization" msgstr "" -#: ../../Zotlabs/Module/Network.php:108 +#: ../../Zotlabs/Module/Network.php:110 msgid "No such group" msgstr "" -#: ../../Zotlabs/Module/Network.php:160 +#: ../../Zotlabs/Module/Network.php:162 msgid "No such channel" msgstr "" -#: ../../Zotlabs/Module/Network.php:172 ../../Zotlabs/Module/Channel.php:246 +#: ../../Zotlabs/Module/Network.php:174 ../../Zotlabs/Module/Channel.php:246 msgid "Search Results For:" msgstr "" -#: ../../Zotlabs/Module/Network.php:248 +#: ../../Zotlabs/Module/Network.php:250 msgid "Privacy group is empty" msgstr "" -#: ../../Zotlabs/Module/Network.php:258 +#: ../../Zotlabs/Module/Network.php:260 msgid "Privacy group: " msgstr "" @@ -9054,10 +9015,6 @@ msgstr "" msgid "System Notifications" msgstr "" -#: ../../Zotlabs/Module/Notifications.php:111 -msgid "Mark all seen" -msgstr "" - #: ../../Zotlabs/Module/Z6trans.php:19 msgid "Update to Hubzilla 5.0 step 2" msgstr "" @@ -9074,6 +9031,18 @@ msgstr "" msgid "from the terminal." msgstr "" +#: ../../Zotlabs/Module/Request.php:80 +msgid "+ Repeat again" +msgstr "" + +#: ../../Zotlabs/Module/Request.php:80 +msgid "- Remove yours" +msgstr "" + +#: ../../Zotlabs/Module/Request.php:80 +msgid "+ Add yours" +msgstr "" + #: ../../Zotlabs/Module/Thing.php:146 msgid "Thing updated" msgstr "" @@ -9285,6 +9254,10 @@ msgstr "" msgid "Edit file permissions" msgstr "" +#: ../../Zotlabs/Module/Filestorage.php:202 +msgid "Set/edit permissions" +msgstr "" + #: ../../Zotlabs/Module/Filestorage.php:203 msgid "Include all files and sub folders" msgstr "" @@ -9445,11 +9418,6 @@ msgstr "" msgid "Permission" msgstr "" -#: ../../Zotlabs/Module/Contactedit.php:431 -#: ../../Zotlabs/Module/Connedit.php:572 -msgid "Affinity" -msgstr "" - #: ../../Zotlabs/Module/Contactedit.php:432 msgid "Content filter" msgstr "" @@ -9815,36 +9783,36 @@ msgstr "" msgid "item" msgstr "" -#: ../../Zotlabs/Module/Item.php:253 ../../Zotlabs/Module/Pin.php:36 +#: ../../Zotlabs/Module/Item.php:254 ../../Zotlabs/Module/Pin.php:37 msgid "Unable to locate original post." msgstr "" -#: ../../Zotlabs/Module/Item.php:541 +#: ../../Zotlabs/Module/Item.php:542 msgid "Empty post discarded." msgstr "" -#: ../../Zotlabs/Module/Item.php:1010 +#: ../../Zotlabs/Module/Item.php:1005 msgid "Duplicate post suppressed." msgstr "" -#: ../../Zotlabs/Module/Item.php:1160 +#: ../../Zotlabs/Module/Item.php:1155 msgid "System error. Post not saved." msgstr "" -#: ../../Zotlabs/Module/Item.php:1200 +#: ../../Zotlabs/Module/Item.php:1195 msgid "Your comment is awaiting approval." msgstr "" -#: ../../Zotlabs/Module/Item.php:1337 +#: ../../Zotlabs/Module/Item.php:1333 msgid "Unable to obtain post information from database." msgstr "" -#: ../../Zotlabs/Module/Item.php:1344 +#: ../../Zotlabs/Module/Item.php:1340 #, php-format msgid "You have reached your limit of %1$.0f top level posts." msgstr "" -#: ../../Zotlabs/Module/Item.php:1351 +#: ../../Zotlabs/Module/Item.php:1347 #, php-format msgid "You have reached your limit of %1$.0f webpages." msgstr "" @@ -10313,7 +10281,7 @@ msgstr "" msgid "The main page content can not be edited!" msgstr "" -#: ../../Zotlabs/Module/Home.php:105 +#: ../../Zotlabs/Module/Home.php:112 #, php-format msgid "Welcome to %s" msgstr "" @@ -11189,15 +11157,15 @@ msgid "" "This role will be used for the first channel created after registration." msgstr "" -#: ../../Zotlabs/Module/Admin/Site.php:344 ../../Zotlabs/Module/Invite.php:411 +#: ../../Zotlabs/Module/Admin/Site.php:344 ../../Zotlabs/Module/Invite.php:394 msgid "Minute(s)" msgstr "" -#: ../../Zotlabs/Module/Admin/Site.php:345 ../../Zotlabs/Module/Invite.php:412 +#: ../../Zotlabs/Module/Admin/Site.php:345 ../../Zotlabs/Module/Invite.php:395 msgid "Hour(s)" msgstr "" -#: ../../Zotlabs/Module/Admin/Site.php:346 ../../Zotlabs/Module/Invite.php:413 +#: ../../Zotlabs/Module/Admin/Site.php:346 ../../Zotlabs/Module/Invite.php:396 msgid "Day(s)" msgstr "" @@ -11222,7 +11190,7 @@ msgid "Time to wait before a registration can be verified" msgstr "" #: ../../Zotlabs/Module/Admin/Site.php:363 -#: ../../Zotlabs/Module/Admin/Site.php:385 ../../Zotlabs/Module/Invite.php:422 +#: ../../Zotlabs/Module/Admin/Site.php:385 ../../Zotlabs/Module/Invite.php:405 msgid "duration up from now" msgstr "" @@ -11915,12 +11883,12 @@ msgstr "" msgid "Link to source" msgstr "" -#: ../../Zotlabs/Module/Cal.php:199 ../../Zotlabs/Module/Photos.php:946 +#: ../../Zotlabs/Module/Cal.php:199 ../../Zotlabs/Module/Photos.php:948 #: ../../Zotlabs/Module/Cdav.php:1026 msgid "Previous" msgstr "" -#: ../../Zotlabs/Module/Cal.php:200 ../../Zotlabs/Module/Photos.php:955 +#: ../../Zotlabs/Module/Cal.php:200 ../../Zotlabs/Module/Photos.php:957 #: ../../Zotlabs/Module/Setup.php:278 ../../Zotlabs/Module/Cdav.php:1027 msgid "Next" msgstr "" @@ -12196,6 +12164,10 @@ msgstr "" msgid "Post not found." msgstr "" +#: ../../Zotlabs/Module/Tagger.php:83 +msgid "comment" +msgstr "" + #: ../../Zotlabs/Module/Tagger.php:123 #, php-format msgid "%1$s tagged %2$s's %3$s with %4$s" @@ -12209,7 +12181,7 @@ msgstr "" msgid "Register is closed" msgstr "" -#: ../../Zotlabs/Module/Invite.php:116 ../../Zotlabs/Module/Invite.php:563 +#: ../../Zotlabs/Module/Invite.php:116 ../../Zotlabs/Module/Invite.php:546 msgid "Note, the invitation code is valid up to" msgstr "" @@ -12268,55 +12240,51 @@ msgstr "" msgid "You have no more invitations available" msgstr "" -#: ../../Zotlabs/Module/Invite.php:366 +#: ../../Zotlabs/Module/Invite.php:360 msgid "Not on xchan" msgstr "" -#: ../../Zotlabs/Module/Invite.php:399 -msgid "All users invitation limit exceeded." -msgstr "" - -#: ../../Zotlabs/Module/Invite.php:417 +#: ../../Zotlabs/Module/Invite.php:400 msgid "Invitation expires after" msgstr "" -#: ../../Zotlabs/Module/Invite.php:518 ../../Zotlabs/Module/Invite.php:557 +#: ../../Zotlabs/Module/Invite.php:501 ../../Zotlabs/Module/Invite.php:540 msgid "Invitation" msgstr "" -#: ../../Zotlabs/Module/Invite.php:548 +#: ../../Zotlabs/Module/Invite.php:531 msgid "Send invitations" msgstr "" -#: ../../Zotlabs/Module/Invite.php:549 +#: ../../Zotlabs/Module/Invite.php:532 msgid "Invitations I am using" msgstr "" -#: ../../Zotlabs/Module/Invite.php:550 +#: ../../Zotlabs/Module/Invite.php:533 msgid "Invitations we are using" msgstr "" -#: ../../Zotlabs/Module/Invite.php:551 +#: ../../Zotlabs/Module/Invite.php:534 msgid "§ Note, the email(s) sent will be recorded in the system logs" msgstr "" -#: ../../Zotlabs/Module/Invite.php:552 +#: ../../Zotlabs/Module/Invite.php:535 msgid "Enter email addresses, one per line:" msgstr "" -#: ../../Zotlabs/Module/Invite.php:553 +#: ../../Zotlabs/Module/Invite.php:536 msgid "Your message:" msgstr "" -#: ../../Zotlabs/Module/Invite.php:554 +#: ../../Zotlabs/Module/Invite.php:537 msgid "Invite template" msgstr "" -#: ../../Zotlabs/Module/Invite.php:556 +#: ../../Zotlabs/Module/Invite.php:539 msgid "Subject:" msgstr "" -#: ../../Zotlabs/Module/Invite.php:562 +#: ../../Zotlabs/Module/Invite.php:545 msgid "Here you may enter personal notes to the recipient(s)" msgstr "" @@ -12439,46 +12407,46 @@ msgid "" "a> on any site containing your channel." msgstr "" -#: ../../Zotlabs/Module/Like.php:111 +#: ../../Zotlabs/Module/Like.php:99 msgid "Like/Dislike" msgstr "" -#: ../../Zotlabs/Module/Like.php:117 +#: ../../Zotlabs/Module/Like.php:105 msgid "This action is restricted to members." msgstr "" -#: ../../Zotlabs/Module/Like.php:118 +#: ../../Zotlabs/Module/Like.php:106 msgid "" "Please <a href=\"rmagic\">login with your $Projectname ID</a> or <a " "href=\"register\">register as a new $Projectname member</a> to continue." msgstr "" -#: ../../Zotlabs/Module/Like.php:171 ../../Zotlabs/Module/Like.php:197 -#: ../../Zotlabs/Module/Like.php:230 +#: ../../Zotlabs/Module/Like.php:159 ../../Zotlabs/Module/Like.php:185 +#: ../../Zotlabs/Module/Like.php:218 msgid "Invalid request." msgstr "" -#: ../../Zotlabs/Module/Like.php:212 +#: ../../Zotlabs/Module/Like.php:200 msgid "thing" msgstr "" -#: ../../Zotlabs/Module/Like.php:253 +#: ../../Zotlabs/Module/Like.php:241 msgid "Channel unavailable." msgstr "" -#: ../../Zotlabs/Module/Like.php:289 +#: ../../Zotlabs/Module/Like.php:277 msgid "Previous action reversed." msgstr "" -#: ../../Zotlabs/Module/Like.php:456 +#: ../../Zotlabs/Module/Like.php:444 msgid "profile" msgstr "" -#: ../../Zotlabs/Module/Like.php:623 +#: ../../Zotlabs/Module/Like.php:611 msgid "Action completed." msgstr "" -#: ../../Zotlabs/Module/Like.php:624 +#: ../../Zotlabs/Module/Like.php:612 msgid "Thank you." msgstr "" @@ -12689,7 +12657,7 @@ msgstr "" msgid "Delete Album" msgstr "" -#: ../../Zotlabs/Module/Photos.php:165 ../../Zotlabs/Module/Photos.php:1057 +#: ../../Zotlabs/Module/Photos.php:165 ../../Zotlabs/Module/Photos.php:1058 msgid "Delete Photo" msgstr "" @@ -12697,134 +12665,138 @@ msgstr "" msgid "No photos selected" msgstr "" -#: ../../Zotlabs/Module/Photos.php:571 +#: ../../Zotlabs/Module/Photos.php:573 msgid "Access to this item is restricted." msgstr "" -#: ../../Zotlabs/Module/Photos.php:614 +#: ../../Zotlabs/Module/Photos.php:616 #, php-format msgid "%1$.2f MB photo storage used." msgstr "" -#: ../../Zotlabs/Module/Photos.php:618 +#: ../../Zotlabs/Module/Photos.php:620 #, php-format msgid "%1$.2f MB of %2$.2f MB photo storage used." msgstr "" -#: ../../Zotlabs/Module/Photos.php:660 +#: ../../Zotlabs/Module/Photos.php:662 msgid "Upload Photos" msgstr "" -#: ../../Zotlabs/Module/Photos.php:664 +#: ../../Zotlabs/Module/Photos.php:666 msgid "Enter an album name" msgstr "" -#: ../../Zotlabs/Module/Photos.php:665 +#: ../../Zotlabs/Module/Photos.php:667 msgid "or select an existing album (doubleclick)" msgstr "" -#: ../../Zotlabs/Module/Photos.php:666 +#: ../../Zotlabs/Module/Photos.php:668 msgid "Create a status post for this upload" msgstr "" -#: ../../Zotlabs/Module/Photos.php:668 +#: ../../Zotlabs/Module/Photos.php:670 msgid "Description (optional)" msgstr "" -#: ../../Zotlabs/Module/Photos.php:756 +#: ../../Zotlabs/Module/Photos.php:758 msgid "Show Newest First" msgstr "" -#: ../../Zotlabs/Module/Photos.php:758 +#: ../../Zotlabs/Module/Photos.php:760 msgid "Show Oldest First" msgstr "" -#: ../../Zotlabs/Module/Photos.php:815 ../../Zotlabs/Module/Photos.php:1355 +#: ../../Zotlabs/Module/Photos.php:817 ../../Zotlabs/Module/Photos.php:1349 msgid "Add Photos" msgstr "" -#: ../../Zotlabs/Module/Photos.php:867 +#: ../../Zotlabs/Module/Photos.php:869 msgid "Permission denied. Access to this item may be restricted." msgstr "" -#: ../../Zotlabs/Module/Photos.php:869 +#: ../../Zotlabs/Module/Photos.php:871 msgid "Photo not available" msgstr "" -#: ../../Zotlabs/Module/Photos.php:927 +#: ../../Zotlabs/Module/Photos.php:929 msgid "Use as profile photo" msgstr "" -#: ../../Zotlabs/Module/Photos.php:928 +#: ../../Zotlabs/Module/Photos.php:930 msgid "Use as cover photo" msgstr "" -#: ../../Zotlabs/Module/Photos.php:935 +#: ../../Zotlabs/Module/Photos.php:937 msgid "Private Photo" msgstr "" -#: ../../Zotlabs/Module/Photos.php:950 +#: ../../Zotlabs/Module/Photos.php:952 msgid "View Full Size" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1031 +#: ../../Zotlabs/Module/Photos.php:1032 msgid "Edit photo" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1033 +#: ../../Zotlabs/Module/Photos.php:1034 msgid "Rotate CW (right)" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1034 +#: ../../Zotlabs/Module/Photos.php:1035 msgid "Rotate CCW (left)" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1037 +#: ../../Zotlabs/Module/Photos.php:1038 msgid "Move photo to album" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1038 +#: ../../Zotlabs/Module/Photos.php:1039 msgid "Enter a new album name" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1039 +#: ../../Zotlabs/Module/Photos.php:1040 msgid "or select an existing one (doubleclick)" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1044 +#: ../../Zotlabs/Module/Photos.php:1045 msgid "Add a Tag" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1052 +#: ../../Zotlabs/Module/Photos.php:1053 msgid "Example: @bob, @Barbara_Jensen, @jim@example.com" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1055 +#: ../../Zotlabs/Module/Photos.php:1056 msgid "Flag as adult in album view" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1125 ../../Zotlabs/Module/Photos.php:1137 -msgid "View all" +#: ../../Zotlabs/Module/Photos.php:1075 +msgid "I like this (toggle)" +msgstr "" + +#: ../../Zotlabs/Module/Photos.php:1076 +msgid "I don't like this (toggle)" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1238 +#: ../../Zotlabs/Module/Photos.php:1232 msgid "Photo Tools" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1247 +#: ../../Zotlabs/Module/Photos.php:1241 msgid "In This Photo:" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1252 +#: ../../Zotlabs/Module/Photos.php:1246 msgid "Map" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1260 +#: ../../Zotlabs/Module/Photos.php:1254 msgctxt "noun" msgid "Likes" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1261 +#: ../../Zotlabs/Module/Photos.php:1255 msgctxt "noun" msgid "Dislikes" msgstr "" @@ -14027,6 +13999,10 @@ msgstr "" msgid "Language App" msgstr "" +#: ../../Zotlabs/Module/Lang.php:80 +msgid "Select an alternate language" +msgstr "" + #: ../../Zotlabs/Module/Rpost.php:117 ../../Zotlabs/Module/Editpost.php:114 msgid "Edit post" msgstr "" @@ -14278,69 +14254,67 @@ msgstr "" msgid "%s - (Experimental)" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:183 +#: ../../Zotlabs/Module/Settings/Display.php:182 msgid "Display Settings" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:184 +#: ../../Zotlabs/Module/Settings/Display.php:183 msgid "Theme Settings" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:185 +#: ../../Zotlabs/Module/Settings/Display.php:184 msgid "Custom Theme Settings" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:186 +#: ../../Zotlabs/Module/Settings/Display.php:185 msgid "Content Settings" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:192 +#: ../../Zotlabs/Module/Settings/Display.php:191 msgid "Display Theme:" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:193 +#: ../../Zotlabs/Module/Settings/Display.php:192 msgid "Select scheme" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:195 -msgid "Preload images before rendering the page" +#: ../../Zotlabs/Module/Settings/Display.php:194 +msgid "Threaded conversation view" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:195 -msgid "" -"The subjective page load time will be longer but the page will be ready when " -"displayed" +#: ../../Zotlabs/Module/Settings/Display.php:194 +msgid "Display replies below their parent message (default yes)" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:196 +#: ../../Zotlabs/Module/Settings/Display.php:195 msgid "Enable user zoom on mobile devices" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:197 +#: ../../Zotlabs/Module/Settings/Display.php:196 msgid "Update browser every xx seconds" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:197 +#: ../../Zotlabs/Module/Settings/Display.php:196 msgid "Minimum of 10 seconds, no maximum" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:198 +#: ../../Zotlabs/Module/Settings/Display.php:197 msgid "Maximum number of conversations to load at any time:" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:198 +#: ../../Zotlabs/Module/Settings/Display.php:197 msgid "Maximum of 30 items" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:199 +#: ../../Zotlabs/Module/Settings/Display.php:198 msgid "Show emoticons (smilies) as images" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:200 +#: ../../Zotlabs/Module/Settings/Display.php:199 msgid "Link post titles to source" msgstr "" -#: ../../Zotlabs/Module/Settings/Display.php:202 +#: ../../Zotlabs/Module/Settings/Display.php:201 msgid "Display new member quick links menu" msgstr "" @@ -14687,10 +14661,6 @@ msgstr "" msgid "Unseen stream activity" msgstr "" -#: ../../Zotlabs/Module/Settings/Channel.php:259 -msgid "Unseen channel activity" -msgstr "" - #: ../../Zotlabs/Module/Settings/Channel.php:260 msgid "Unseen private messages" msgstr "" @@ -14730,10 +14700,6 @@ msgstr "" msgid "System critical alerts" msgstr "" -#: ../../Zotlabs/Module/Settings/Channel.php:267 -msgid "New connections" -msgstr "" - #: ../../Zotlabs/Module/Settings/Channel.php:268 msgid "System Registrations" msgstr "" @@ -14742,10 +14708,6 @@ msgstr "" msgid "Unseen shared files" msgstr "" -#: ../../Zotlabs/Module/Settings/Channel.php:270 -msgid "Unseen public stream activity" -msgstr "" - #: ../../Zotlabs/Module/Settings/Channel.php:271 msgid "Unseen likes and dislikes" msgstr "" diff --git a/vendor/bakame/http-structured-fields/LICENSE b/vendor/bakame/http-structured-fields/LICENSE new file mode 100644 index 000000000..225c502ed --- /dev/null +++ b/vendor/bakame/http-structured-fields/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Nyamagana Butera + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/bakame/http-structured-fields/composer.json b/vendor/bakame/http-structured-fields/composer.json new file mode 100644 index 000000000..9a8241ee2 --- /dev/null +++ b/vendor/bakame/http-structured-fields/composer.json @@ -0,0 +1,106 @@ +{ + "name": "bakame/http-structured-fields", + "description": "A PHP library that parses, validates and serializes HTTP structured fields according to RFC9561 and RFC8941", + "type": "library", + "keywords": [ + "http", + "http headers", + "http trailers", + "headers", + "trailers", + "structured fields", + "structured headers", + "structured trailers", + "structured values", + "parser", + "serializer", + "validation", + "rfc8941", + "rfc9651" + ], + "license": "MIT", + "authors": [ + { + "name" : "Ignace Nyamagana Butera", + "email" : "nyamsprod@gmail.com", + "homepage" : "https://github.com/nyamsprod/", + "role" : "Developer" + } + ], + "support": { + "docs": "https://github.com/bakame-php/http-structured-fields", + "issues": "https://github.com/bakame-php/http-structured-fields/issues", + "source": "https://github.com/bakame-php/http-structured-fields" + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/nyamsprod" + } + ], + "require": { + "php" : "^8.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.65.0", + "httpwg/structured-field-tests": "*@dev", + "phpstan/phpstan": "^2.0.3", + "phpstan/phpstan-strict-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0.1", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpunit/phpunit": "^10.5.38 || ^11.5.0", + "symfony/var-dumper": "^6.4.15 || ^v7.2.0", + "bakame/aide-base32": "dev-main", + "phpbench/phpbench": "^1.3.1" + }, + "autoload": { + "psr-4": { + "Bakame\\Http\\StructuredFields\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Bakame\\Http\\StructuredFields\\": "tests/" + } + }, + "scripts": { + "benchmark": "phpbench run --report=default", + "phpcs": "php-cs-fixer fix --dry-run --diff -vvv --allow-risky=yes --ansi", + "phpcs:fix": "php-cs-fixer fix -vvv --allow-risky=yes --ansi", + "phpstan": "phpstan analyse -c phpstan.neon --ansi --memory-limit 192M", + "phpunit": "XDEBUG_MODE=coverage phpunit --coverage-text", + "phpunit:min": "phpunit --no-coverage", + "test": [ + "@phpunit", + "@phpstan", + "@phpcs" + ] + }, + "scripts-descriptions": { + "benchmark": "Runs parser benchmark", + "phpstan": "Runs complete codebase static analysis", + "phpunit": "Runs unit and functional testing", + "phpcs": "Runs coding style testing", + "phpcs:fix": "Fix coding style issues", + "test": "Runs all tests" + }, + "repositories": [ + { + "type": "package", + "package": { + "name": "httpwg/structured-field-tests", + "version": "dev-main", + "source": { + "url": "https://github.com/httpwg/structured-field-tests.git", + "type": "git", + "reference": "main" + } + } + } + ], + "extra": { + "branch-alias": { + "dev-develop": "1.x-dev" + } + } +} diff --git a/vendor/bakame/http-structured-fields/src/Bytes.php b/vendor/bakame/http-structured-fields/src/Bytes.php new file mode 100644 index 000000000..aa747b76b --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Bytes.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use Stringable; +use Throwable; + +use function base64_decode; +use function base64_encode; +use function preg_match; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.3.5 + */ +final class Bytes +{ + private function __construct(private readonly string $value) + { + } + + /** + * Returns a new instance from a Base64 encoded string. + */ + public static function fromEncoded(Stringable|string $encoded): self + { + $encoded = (string) $encoded; + if (1 !== preg_match('/^[a-z\d+\/=]*$/i', $encoded)) { + throw new SyntaxError('The byte sequence '.$encoded.' contains invalid characters.'); + } + + $decoded = base64_decode($encoded, true); + if (false === $decoded) { + throw new SyntaxError('Unable to base64 decode the byte sequence '.$encoded); + } + + return new self($decoded); + } + + public static function tryFromEncoded(Stringable|string $encoded): ?self + { + try { + return self::fromEncoded($encoded); + } catch (Throwable) { + return null; + } + } + + /** + * Returns a new instance from a raw decoded string. + */ + public static function fromDecoded(Stringable|string $decoded): self + { + return new self((string) $decoded); + } + + /** + * Returns the decoded string. + */ + public function decoded(): string + { + return $this->value; + } + + /** + * Returns the base64 encoded string. + */ + public function encoded(): string + { + return base64_encode($this->value); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->value === $this->value; + } + + public function type(): Type + { + return Type::Bytes; + } +} diff --git a/vendor/bakame/http-structured-fields/src/DataType.php b/vendor/bakame/http-structured-fields/src/DataType.php new file mode 100644 index 000000000..8cc5f5395 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/DataType.php @@ -0,0 +1,45 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use Exception; +use Stringable; + +enum DataType: string +{ + case List = 'list'; + case InnerList = 'innerlist'; + case Parameters = 'parameters'; + case Dictionary = 'dictionary'; + case Item = 'item'; + + /** + * @throws SyntaxError|Exception + */ + public function parse(Stringable|string $httpValue, Ietf $rfc = Ietf::Rfc9651): OuterList|InnerList|Parameters|Dictionary|Item + { + return match ($this) { + self::List => OuterList::fromHttpValue($httpValue, $rfc), + self::Dictionary => Dictionary::fromHttpValue($httpValue, $rfc), + self::Item => Item::fromHttpValue($httpValue, $rfc), + self::InnerList => InnerList::fromHttpValue($httpValue, $rfc), + self::Parameters => Parameters::fromHttpValue($httpValue, $rfc), + }; + } + + /** + * @throws SyntaxError|Exception + */ + public function serialize(iterable $data, Ietf $rfc = Ietf::Rfc9651): string + { + return (match ($this) { + self::List => OuterList::fromPairs($data), + self::Dictionary => Dictionary::fromPairs($data), + self::Item => Item::fromPair([...$data]), + self::InnerList => InnerList::fromPair([...$data]), + self::Parameters => Parameters::fromPairs($data), + })->toHttpValue($rfc); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Dictionary.php b/vendor/bakame/http-structured-fields/src/Dictionary.php new file mode 100644 index 000000000..8a318695c --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Dictionary.php @@ -0,0 +1,788 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use ArrayAccess; +use Bakame\Http\StructuredFields\Validation\Violation; +use CallbackFilterIterator; +use Countable; +use DateTimeInterface; +use Exception; +use Iterator; +use IteratorAggregate; +use Stringable; +use Throwable; + +use function array_key_exists; +use function array_keys; +use function array_map; +use function count; +use function implode; +use function is_bool; +use function is_int; +use function is_iterable; +use function is_string; +use function uasort; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.2 + * + * @phpstan-import-type SfMemberInput from StructuredFieldProvider + * + * @implements ArrayAccess<string, InnerList|Item> + * @implements IteratorAggregate<int, array{0:string, 1:InnerList|Item}> + */ +final class Dictionary implements ArrayAccess, Countable, IteratorAggregate +{ + /** @var array<string, InnerList|Item> */ + private readonly array $members; + + /** + * @param iterable<string, SfMemberInput> $members + */ + private function __construct(iterable $members = []) + { + $filteredMembers = []; + foreach ($members as $key => $member) { + $filteredMembers[Key::from($key)->value] = Member::innerListOrItem($member); + } + + $this->members = $filteredMembers; + } + + /** + * Returns a new instance. + */ + public static function new(): self + { + return new self(); + } + + /** + * Returns a new instance from an associative iterable construct. + * + * its keys represent the dictionary entry name + * its values represent the dictionary entry value + * + * @param StructuredFieldProvider|iterable<string, SfMemberInput> $members + */ + public static function fromAssociative(StructuredFieldProvider|iterable $members): self + { + if ($members instanceof StructuredFieldProvider) { + $structuredField = $members->toStructuredField(); + + return match (true) { + $structuredField instanceof Dictionary, + $structuredField instanceof Parameters => new self($structuredField->toAssociative()), + default => throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a structured field container; '.$structuredField::class.' given.'), + }; + } + + return new self($members); + } + + /** + * Returns a new instance from a pair iterable construct. + * + * Each member is composed of an array with two elements + * the first member represents the instance entry key + * the second member represents the instance entry value + * + * @param StructuredFieldProvider|Dictionary|Parameters|iterable<array{0:string, 1?:SfMemberInput}> $pairs + */ + public static function fromPairs(StructuredFieldProvider|Dictionary|Parameters|iterable $pairs): self + { + if ($pairs instanceof StructuredFieldProvider) { + $pairs = $pairs->toStructuredField(); + } + + if (!is_iterable($pairs)) { + throw new InvalidArgument('The "'.$pairs::class.'" instance can not be used for creating a .'.self::class.' structured field.'); + } + + return match (true) { + $pairs instanceof Dictionary, + $pairs instanceof Parameters => new self($pairs->toAssociative()), + default => new self((function (iterable $pairs) { + foreach ($pairs as [$key, $member]) { + yield $key => Member::innerListOrItemFromPair($member); + } + })($pairs)), + }; + } + + /** + * Returns an instance from an HTTP textual representation compliant with RFC9651. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.2 + * + * @throws StructuredFieldError|Throwable + */ + public static function fromRfc9651(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc9651); + } + + /** + * Returns an instance from an HTTP textual representation compliant with RFC8941. + * + * @see https://www.rfc-editor.org/rfc/rfc8941.html#section-3.2 + * + * @throws StructuredFieldError|Throwable + */ + public static function fromRfc8941(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc8941); + } + + /** + * Returns an instance from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.2 + * + * @throws StructuredFieldError|Exception If the string is not a valid + */ + public static function fromHttpValue(Stringable|string $httpValue, Ietf $rfc = Ietf::Rfc9651): self + { + return self::fromPairs((new Parser($rfc))->parseDictionary($httpValue)); /* @phpstan-ignore-line */ + } + + public function toRfc9651(): string + { + return $this->toHttpValue(Ietf::Rfc9651); + } + + public function toRfc8941(): string + { + return $this->toHttpValue(Ietf::Rfc8941); + } + + public function toHttpValue(Ietf $rfc = Ietf::Rfc9651): string + { + $formatter = static fn (Item|InnerList $member, string $offset): string => match (true) { + $member instanceof Item && true === $member->value() => $offset.$member->parameters()->toHttpValue($rfc), + default => $offset.'='.$member->toHttpValue($rfc), + }; + + return implode(', ', array_map($formatter, $this->members, array_keys($this->members))); + } + + public function __toString(): string + { + return $this->toHttpValue(); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->toHttpValue() === $this->toHttpValue(); + } + + /** + * Apply the callback if the given "condition" is (or resolves to) true. + * + * @param (callable($this): bool)|bool $condition + * @param callable($this): (self|null) $onSuccess + * @param ?callable($this): (self|null) $onFail + */ + public function when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null): self + { + if (!is_bool($condition)) { + $condition = $condition($this); + } + + return match (true) { + $condition => $onSuccess($this), + null !== $onFail => $onFail($this), + default => $this, + } ?? $this; + } + + public function count(): int + { + return count($this->members); + } + + /** + * Tells whether the instance contains no members. + */ + public function isEmpty(): bool + { + return !$this->isNotEmpty(); + } + + /** + * Tells whether the instance contains any members. + */ + public function isNotEmpty(): bool + { + return [] !== $this->members; + } + + /** + * @return Iterator<string, InnerList|Item> + */ + public function toAssociative(): Iterator + { + yield from $this->members; + } + + /** + * Returns an iterable construct of dictionary pairs. + * + * @return Iterator<int, array{0:string, 1:InnerList|Item}> + */ + public function getIterator(): Iterator + { + foreach ($this->members as $index => $member) { + yield [$index, $member]; + } + } + + /** + * Returns an ordered list of the instance keys. + * + * @return array<string> + */ + public function keys(): array + { + return array_keys($this->members); + } + + /** + * @return array<int> + */ + public function indices(): array + { + return array_keys($this->keys()); + } + + /** + * Tells whether the instance contain a members at the specified offsets. + */ + public function hasKeys(string ...$keys): bool + { + foreach ($keys as $key) { + if (!array_key_exists($key, $this->members)) { + return false; + } + } + + return [] !== $keys; + } + + /** + * Returns true only if the instance only contains the listed keys, false otherwise. + * + * @param array<string> $keys + */ + public function allowedKeys(array $keys): bool + { + foreach ($this->members as $key => $member) { + if (!in_array($key, $keys, true)) { + return false; + } + } + + return [] !== $keys; + } + + /** + * @param ?callable(Item|InnerList): (bool|string) $validate + * + * @throws InvalidOffset|Violation|StructuredFieldError + */ + public function getByKey(string $key, ?callable $validate = null): Item|InnerList + { + $value = $this->members[$key] ?? throw InvalidOffset::dueToKeyNotFound($key); + if (null === $validate || true === ($exceptionMessage = $validate($value))) { + return $value; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The parameter '{key}' whose value is '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{key}' => $key, '{value}' => $value->toHttpValue()])); + } + + /** + * Tells whether a pair is attached to the given index position. + */ + public function hasIndices(int ...$indexes): bool + { + $max = count($this->members); + foreach ($indexes as $index) { + if (null === $this->filterIndex($index, $max)) { + return false; + } + } + + return [] !== $indexes; + } + + /** + * Filters and format instance index. + */ + private function filterIndex(int $index, ?int $max = null): ?int + { + $max ??= count($this->members); + + return match (true) { + [] === $this->members, + 0 > $max + $index, + 0 > $max - $index - 1 => null, + 0 > $index => $max + $index, + default => $index, + }; + } + + /** + * Returns the item or the inner-list and its key as attached to the given + * collection according to their index position otherwise throw. + * + * @param ?callable(Item|InnerList, string): (bool|string) $validate + * + * @throws InvalidOffset|Violation|StructuredFieldError + * + * @return array{0:string, 1:InnerList|Item} + */ + public function getByIndex(int $index, ?callable $validate = null): array + { + $foundOffset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + foreach ($this as $offset => $pair) { + if ($offset === $foundOffset) { + break; + } + } + + if (!isset($pair)) { + throw InvalidOffset::dueToIndexNotFound($index); + } + + if (null === $validate || true === ($exceptionMessage = $validate($pair[1], $pair[0]))) { + return $pair; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The member at position '{index}' whose key is '{key}' with the value '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{index}' => $index, '{key}' => $pair[0], '{value}' => $pair[1]->toHttpValue()])); + } + + /** + * Returns the key associated with the given index or null otherwise. + */ + public function indexByKey(string $key): ?int + { + foreach ($this as $index => $member) { + if ($key === $member[0]) { + return $index; + } + } + + return null; + } + + /** + * Returns the index associated with the given key or null otherwise. + */ + public function keyByIndex(int $index): ?string + { + $index = $this->filterIndex($index); + if (null === $index) { + return null; + } + + foreach ($this as $offset => $member) { + if ($offset === $index) { + return $member[0]; + } + } + + return null; + } + + /** + * Returns the first member whether it is an item or an inner-list and its key as attached to the given + * collection according to their index position otherwise returns an empty array. + * + * @return array{0:string, 1:InnerList|Item}|array{} + */ + public function first(): array + { + try { + return $this->getByIndex(0); + } catch (StructuredFieldError) { + return []; + } + } + + /** + * Returns the first member whether it is an item or an inner-list and its key as attached to the given + * collection according to their index position otherwise returns an empty array. + * + * @return array{0:string, 1:InnerList|Item}|array{} + */ + public function last(): array + { + try { + return $this->getByIndex(-1); + } catch (StructuredFieldError) { + return []; + } + } + + /** + * Adds a member at the end of the instance otherwise updates the value associated with the key if already present. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param SfMemberInput $member + * + * @throws SyntaxError If the string key is not a valid + */ + public function add( + string $key, + iterable|StructuredFieldProvider|Dictionary|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $members = $this->members; + $members[Key::from($key)->value] = Member::innerListOrItem($member); + + return $this->newInstance($members); + } + + /** + * @param array<string, InnerList|Item> $members + */ + private function newInstance(array $members): self + { + foreach ($members as $offset => $member) { + if (!isset($this->members[$offset]) || !$this->members[$offset]->equals($member)) { + return new self($members); + } + } + + return $this; + } + + /** + * Deletes members associated with the list of submitted keys. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + */ + private function remove(string|int ...$offsets): self + { + if ([] === $this->members || [] === $offsets) { + return $this; + } + + $keys = array_keys($this->members); + $max = count($keys); + $reducer = fn (array $carry, string|int $key): array => match (true) { + is_string($key) && (false !== ($position = array_search($key, $keys, true))), + is_int($key) && (null !== ($position = $this->filterIndex($key, $max))) => [$position => true] + $carry, + default => $carry, + }; + + $indices = array_reduce($offsets, $reducer, []); + + return match (true) { + [] === $indices => $this, + $max === count($indices) => self::new(), + default => self::fromPairs((function (array $offsets) { + foreach ($this->getIterator() as $offset => $pair) { + if (!array_key_exists($offset, $offsets)) { + yield $pair; + } + } + })($indices)), + }; + } + + /** + * Deletes members associated with the list using the member pair offset. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + */ + public function removeByIndices(int ...$indices): self + { + return $this->remove(...$indices); + } + + /** + * Deletes members associated with the list using the member key. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + */ + public function removeByKeys(string ...$keys): self + { + return $this->remove(...$keys); + } + + /** + * Adds a member at the end of the instance and deletes any previous reference to the key if present. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param SfMemberInput $member + * @throws SyntaxError If the string key is not a valid + */ + public function append( + string $key, + iterable|StructuredFieldProvider|Dictionary|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $members = $this->members; + unset($members[$key]); + + return $this->newInstance([...$members, Key::from($key)->value => Member::innerListOrItem($member)]); + } + + /** + * Adds a member at the beginning of the instance and deletes any previous reference to the key if present. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param SfMemberInput $member + * + * @throws SyntaxError If the string key is not a valid + */ + public function prepend( + string $key, + iterable|StructuredFieldProvider|Dictionary|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $members = $this->members; + unset($members[$key]); + + return $this->newInstance([Key::from($key)->value => Member::innerListOrItem($member), ...$members]); + } + + /** + * Inserts pairs at the end of the container. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param array{0:string, 1:SfMemberInput} ...$pairs + */ + public function push(array ...$pairs): self + { + return match (true) { + [] === $pairs => $this, + default => self::fromPairs((function (iterable $pairs) { + yield from $this->getIterator(); + yield from $pairs; + })($pairs)), + }; + } + + /** + * Inserts pairs at the beginning of the container. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param array{0:string, 1:SfMemberInput} ...$pairs + */ + public function unshift(array ...$pairs): self + { + return match (true) { + [] === $pairs => $this, + default => self::fromPairs((function (iterable $pairs) { + yield from $pairs; + yield from $this->getIterator(); + })($pairs)), + }; + } + + /** + * Insert a member pair using its offset. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param array{0:string, 1:SfMemberInput} ...$members + */ + public function insert(int $index, array ...$members): self + { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + + return match (true) { + [] === $members => $this, + 0 === $offset => $this->unshift(...$members), + count($this->members) === $offset => $this->push(...$members), + default => (function (Iterator $newMembers) use ($offset, $members) { + $newMembers = iterator_to_array($newMembers); + array_splice($newMembers, $offset, 0, $members); + + return self::fromPairs($newMembers); + })($this->getIterator()), + }; + } + + /** + * Replace a member pair using its offset. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param array{0:string, 1:SfMemberInput} $pair + */ + public function replace(int $index, array $pair): self + { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + $pair[1] = Member::innerListOrItem($pair[1]); + $pairs = iterator_to_array($this->getIterator()); + + return match (true) { + $pairs[$offset][0] === $pair[0] && $pairs[$offset][1]->equals($pair[1]) => $this, + default => self::fromPairs(array_replace($pairs, [$offset => $pair])), + }; + } + + /** + * Merges multiple instances using iterable associative structures. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param StructuredFieldProvider|Dictionary|Parameters|iterable<string, SfMemberInput> ...$others + */ + public function mergeAssociative(StructuredFieldProvider|iterable ...$others): self + { + $members = $this->members; + foreach ($others as $other) { + if ($other instanceof StructuredFieldProvider) { + $other = $other->toStructuredField(); + if (!is_iterable($other)) { + throw new InvalidArgument('The "'.$other::class.'" instance can not be used for creating a .'.self::class.' structured field.'); + } + } + + if ($other instanceof self || $other instanceof Parameters) { + $other = $other->toAssociative(); + } + + foreach ($other as $key => $value) { + $members[$key] = $value; + } + } + + return new self($members); + } + + /** + * Merges multiple instances using iterable pairs. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param StructuredFieldProvider|Dictionary|Parameters|iterable<array{0:string, 1:SfMemberInput}> ...$others + */ + public function mergePairs(StructuredFieldProvider|Dictionary|Parameters|iterable ...$others): self + { + $members = $this->members; + foreach ($others as $other) { + if (!$other instanceof self) { + $other = self::fromPairs($other); + } + foreach ($other->toAssociative() as $key => $value) { + $members[$key] = $value; + } + } + + return new self($members); + } + + /** + * @param string $offset + */ + public function offsetExists(mixed $offset): bool + { + return $this->hasKeys($offset); + } + + /** + * @param string $offset + * + * @throws StructuredFieldError + */ + public function offsetGet(mixed $offset): InnerList|Item + { + return $this->getByKey($offset); + } + + public function offsetUnset(mixed $offset): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + public function offsetSet(mixed $offset, mixed $value): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + /** + * Run a map over each container members. + * + * @template TMap + * + * @param callable(array{0:string, 1:Item|InnerList}, int): TMap $callback + * + * @return Iterator<TMap> + */ + public function map(callable $callback): Iterator + { + foreach ($this as $offset => $member) { + yield ($callback)($member, $offset); + } + } + + /** + * @param callable(TInitial|null, array{0:string, 1:Item|InnerList}, int): TInitial $callback + * @param TInitial|null $initial + * + * @template TInitial + * + * @return TInitial|null + */ + public function reduce(callable $callback, mixed $initial = null): mixed + { + foreach ($this as $offset => $pair) { + $initial = $callback($initial, $pair, $offset); + } + + return $initial; + } + + /** + * Run a filter over each container members. + * + * @param callable(array{0:string, 1:InnerList|Item}, int): bool $callback + */ + public function filter(callable $callback): self + { + return self::fromPairs(new CallbackFilterIterator($this, $callback)); + } + + /** + * Sort a container by value using a callback. + * + * @param callable(array{0:string, 1:InnerList|Item}, array{0:string, 1:InnerList|Item}): int $callback + */ + public function sort(callable $callback): self + { + $members = iterator_to_array($this); + uasort($members, $callback); + + return self::fromPairs($members); + } +} diff --git a/vendor/bakame/http-structured-fields/src/DisplayString.php b/vendor/bakame/http-structured-fields/src/DisplayString.php new file mode 100644 index 000000000..361f91ec2 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/DisplayString.php @@ -0,0 +1,103 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use Stringable; +use Throwable; + +use function preg_match; +use function preg_replace_callback; +use function rawurldecode; +use function rawurlencode; +use function str_contains; + +/** + * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-sfbis#section-4.2.10 + */ +final class DisplayString +{ + private function __construct(private readonly string $value) + { + } + + public static function tryFromEncoded(Stringable|string $encoded): ?self + { + try { + return self::fromEncoded($encoded); + } catch (Throwable) { + return null; + } + } + + /** + * Returns a new instance from a Base64 encoded string. + */ + public static function fromEncoded(Stringable|string $encoded): self + { + $encoded = (string) $encoded; + + if (1 === preg_match('/[^\x20-\x7E]/i', $encoded)) { + throw new SyntaxError('The display string '.$encoded.' contains invalid characters.'); + } + + if (!str_contains($encoded, '%')) { + return new self($encoded); + } + + if (1 === preg_match('/%(?![0-9a-f]{2})/', $encoded)) { + throw new SyntaxError('The display string '.$encoded.' contains invalid utf-8 encoded sequence.'); + } + + $decoded = (string) preg_replace_callback( + ',%[a-f0-9]{2},', + fn (array $matches): string => rawurldecode($matches[0]), + $encoded + ); + + if (1 !== preg_match('//u', $decoded)) { + throw new SyntaxError('The display string '.$encoded.' contains invalid characters.'); + } + + return new self($decoded); + } + + /** + * Returns a new instance from a raw decoded string. + */ + public static function fromDecoded(Stringable|string $decoded): self + { + return new self((string) $decoded); + } + + /** + * Returns the decoded string. + */ + public function decoded(): string + { + return $this->value; + } + + /** + * Returns the base64 encoded string. + */ + public function encoded(): string + { + return (string) preg_replace_callback( + '/[%"\x00-\x1F\x7F-\xFF]/', + static fn (array $matches): string => strtolower(rawurlencode($matches[0])), + $this->value + ); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->value === $this->value; + } + + public function type(): Type + { + return Type::DisplayString; + } +} diff --git a/vendor/bakame/http-structured-fields/src/ForbiddenOperation.php b/vendor/bakame/http-structured-fields/src/ForbiddenOperation.php new file mode 100644 index 000000000..f1edbdef4 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/ForbiddenOperation.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use LogicException; + +final class ForbiddenOperation extends LogicException implements StructuredFieldError +{ +} diff --git a/vendor/bakame/http-structured-fields/src/Ietf.php b/vendor/bakame/http-structured-fields/src/Ietf.php new file mode 100644 index 000000000..a98e16e20 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Ietf.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use DateTimeImmutable; +use DateTimeZone; + +enum Ietf +{ + case Rfc8941; + case Rfc9651; + + public function uri(): string + { + return match ($this) { + self::Rfc9651 => 'https://www.rfc-editor.org/rfc/rfc9651.html', + self::Rfc8941 => 'https://www.rfc-editor.org/rfc/rfc8941.html', + }; + } + + public function publishedAt(): DateTimeImmutable + { + return new DateTimeImmutable(match ($this) { + self::Rfc9651 => '2024-09-01', + self::Rfc8941 => '2021-02-01', + }, new DateTimeZone('UTC')); + } + + public function isActive(): bool + { + return self::Rfc9651 === $this; + } + + public function isObsolete(): bool + { + return !$this->isActive(); + } + + public function supports(mixed $value): bool + { + if ($value instanceof StructuredFieldProvider) { + $value = $value->toStructuredField(); + } + + if ($value instanceof OuterList || + $value instanceof InnerList || + $value instanceof Dictionary || + $value instanceof Parameters || + $value instanceof Item + ) { + try { + $value->toHttpValue($this); + + return true; + } catch (MissingFeature) { + return false; + } + } + + if (!$value instanceof Type) { + $value = Type::tryFromVariable($value); + } + + return match ($value) { + null => false, + Type::DisplayString, + Type::Date => self::Rfc8941 !== $this, + default => true, + }; + } +} diff --git a/vendor/bakame/http-structured-fields/src/InnerList.php b/vendor/bakame/http-structured-fields/src/InnerList.php new file mode 100644 index 000000000..8a9a3e734 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/InnerList.php @@ -0,0 +1,478 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use ArrayAccess; +use Bakame\Http\StructuredFields\Validation\Violation; +use Countable; +use DateTimeInterface; +use Iterator; +use IteratorAggregate; +use Stringable; + +use function array_filter; +use function array_is_list; +use function array_map; +use function array_replace; +use function array_splice; +use function array_values; +use function count; +use function implode; +use function uasort; + +use const ARRAY_FILTER_USE_BOTH; +use const ARRAY_FILTER_USE_KEY; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.1 + * + * @phpstan-import-type SfType from StructuredFieldProvider + * @phpstan-import-type SfTypeInput from StructuredFieldProvider + * @phpstan-import-type SfItemInput from StructuredFieldProvider + * @phpstan-import-type SfItemPair from StructuredFieldProvider + * @phpstan-import-type SfInnerListPair from StructuredFieldProvider + * @phpstan-import-type SfParameterInput from StructuredFieldProvider + * + * @implements ArrayAccess<int, Item> + * @implements IteratorAggregate<int, Item> + */ +final class InnerList implements ArrayAccess, Countable, IteratorAggregate +{ + use ParameterAccess; + + /** @var list<Item> */ + private readonly array $members; + private readonly Parameters $parameters; + + /** + * @param iterable<SfItemInput|SfItemPair> $members + */ + private function __construct(iterable $members, ?Parameters $parameters = null) + { + $this->members = array_map(Member::item(...), array_values([...$members])); + $this->parameters = $parameters ?? Parameters::new(); + } + + /** + * Returns an instance from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1 + */ + public static function fromHttpValue(Stringable|string $httpValue, Ietf $rfc = Ietf::Rfc9651): self + { + return self::fromPair((new Parser($rfc))->parseInnerList($httpValue)); + } + + /** + * Returns a new instance with an iter. + * + * @param iterable<SfItemInput> $value + * @param Parameters|iterable<string, SfItemInput> $parameters + */ + public static function fromAssociative( + iterable $value, + StructuredFieldProvider|Parameters|iterable $parameters + ): self { + if ($parameters instanceof StructuredFieldProvider) { + $parameters = $parameters->toStructuredField(); + if (!$parameters instanceof Parameters) { + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Parameters::class.'; '.$parameters::class.' given.'); + } + } + + if (!$parameters instanceof Parameters) { + return new self($value, Parameters::fromAssociative($parameters)); + } + + return new self($value, $parameters); + } + + /** + * @param array{0:iterable<SfItemInput>, 1?:Parameters|SfParameterInput}|array<mixed> $pair + */ + public static function fromPair(array $pair = []): self + { + if ([] === $pair) { + return self::new(); + } + + if (!array_is_list($pair) || 2 < count($pair)) { + throw new SyntaxError('The pair must be represented by an non-empty array as a list containing at most 2 members.'); + } + + if (1 === count($pair)) { + return new self($pair[0]); + } + + if ($pair[1] instanceof StructuredFieldProvider) { + $pair[1] = $pair[1]->toStructuredField(); + if (!$pair[1] instanceof Parameters) { + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Parameters::class.'; '.$pair[1]::class.' given.'); + } + } + + if (!$pair[1] instanceof Parameters) { + return new self($pair[0], Parameters::fromPairs($pair[1])); + } + + return new self($pair[0], $pair[1]); + } + + /** + * Returns a new instance. + * + * @param StructuredFieldProvider|Item|SfTypeInput|SfItemPair ...$members + */ + public static function new( + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|array|string|int|float|bool ...$members + ): self { + return new self($members); + } + + public static function fromRfc9651(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc9651); + } + + public static function fromRfc8941(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc8941); + } + + public function toHttpValue(Ietf $rfc = Ietf::Rfc9651): string + { + return '('.implode(' ', array_map(fn (Item $value): string => $value->toHttpValue($rfc), $this->members)).')'.$this->parameters->toHttpValue($rfc); + } + + public function toRfc9651(): string + { + return $this->toHttpValue(Ietf::Rfc9651); + } + + public function toRfc8941(): string + { + return $this->toHttpValue(Ietf::Rfc8941); + } + + public function __toString(): string + { + return $this->toHttpValue(); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->toHttpValue() === $this->toHttpValue(); + } + + /** + * Apply the callback if the given "condition" is (or resolves to) true. + * + * @param (callable($this): bool)|bool $condition + * @param callable($this): (self|null) $onSuccess + * @param ?callable($this): (self|null) $onFail + */ + public function when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null): self + { + if (!is_bool($condition)) { + $condition = $condition($this); + } + + return match (true) { + $condition => $onSuccess($this), + null !== $onFail => $onFail($this), + default => $this, + } ?? $this; + } + + /** + * @return array{0:list<Item>, 1:Parameters} + */ + public function toPair(): array + { + return [$this->members, $this->parameters]; + } + + public function getIterator(): Iterator + { + yield from $this->members; + } + + public function count(): int + { + return count($this->members); + } + + public function isEmpty(): bool + { + return !$this->isNotEmpty(); + } + + public function isNotEmpty(): bool + { + return [] !== $this->members; + } + + /** + * @return array<int> + */ + public function indices(): array + { + return array_keys($this->members); + } + + public function hasIndices(int ...$indices): bool + { + $max = count($this->members); + foreach ($indices as $offset) { + if (null === $this->filterIndex($offset, $max)) { + return false; + } + } + + return [] !== $indices; + } + + private function filterIndex(int $index, ?int $max = null): ?int + { + $max ??= count($this->members); + + return match (true) { + [] === $this->members, + 0 > $max + $index, + 0 > $max - $index - 1 => null, + 0 > $index => $max + $index, + default => $index, + }; + } + + /** + * @param ?callable(Item): (bool|string) $validate + * + * @throws SyntaxError|Violation|StructuredFieldError + */ + public function getByIndex(int $index, ?callable $validate = null): Item + { + $value = $this->members[$this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index)]; + if (null === $validate) { + return $value; + } + + if (true === ($exceptionMessage = $validate($value))) { + return $value; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The item at '{index}' whose value is '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{index}' => $index, '{value}' => $value->toHttpValue()])); + } + + public function first(): ?Item + { + return $this->members[0] ?? null; + } + + public function last(): ?Item + { + return $this->members[$this->filterIndex(-1)] ?? null; + } + + public function withParameters(StructuredFieldProvider|Parameters $parameters): static + { + if ($parameters instanceof StructuredFieldProvider) { + $parameters = $parameters->toStructuredField(); + if (!$parameters instanceof Parameters) { + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Parameters::class.'; '.$parameters::class.' given.'); + } + } + + return $this->parameters->equals($parameters) ? $this : new self($this->members, $parameters); + } + + /** + * Inserts members at the beginning of the list. + */ + public function unshift( + StructuredFieldProvider|OuterList|Dictionary|InnerList|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ): self { + $membersToAdd = array_reduce( + $members, + function (array $carry, $member) { + if ($member instanceof StructuredFieldProvider) { + $member = $member->toStructuredField(); + } + + return [...$carry, ...$member instanceof InnerList ? [...$member] : [$member]]; + }, + [] + ); + + return match (true) { + [] === $membersToAdd => $this, + default => new self([...array_values($membersToAdd), ...$this->members], $this->parameters), + }; + } + + /** + * Inserts members at the end of the list. + */ + public function push( + StructuredFieldProvider|OuterList|Dictionary|InnerList|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ): self { + $membersToAdd = array_reduce( + $members, + function (array $carry, $member) { + if ($member instanceof StructuredFieldProvider) { + $member = $member->toStructuredField(); + } + + return [...$carry, ...$member instanceof InnerList ? [...$member] : [$member]]; + }, + [] + ); + + return match (true) { + [] === $membersToAdd => $this, + default => new self([...$this->members, ...array_values($membersToAdd)], $this->parameters), + }; + } + + /** + * Inserts members starting at the given index. + * + * @throws InvalidOffset If the index does not exist + */ + public function insert( + int $index, + StructuredFieldProvider|OuterList|Dictionary|InnerList|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ): self { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + + return match (true) { + 0 === $offset => $this->unshift(...$members), + count($this->members) === $offset => $this->push(...$members), + [] === $members => $this, + default => (function (array $newMembers) use ($offset, $members) { + array_splice($newMembers, $offset, 0, $members); + + return new self($newMembers, $this->parameters); + })($this->members), + }; + } + + public function replace( + int $index, + StructuredFieldProvider|OuterList|Dictionary|InnerList|Parameters|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + $member = Member::item($member); + + return match (true) { + $member->equals($this->members[$offset]) => $this, + default => new self(array_replace($this->members, [$offset => $member]), $this->parameters), + }; + } + + public function removeByIndices(int ...$indices): self + { + $max = count($this->members); + $indices = array_filter( + array_map(fn (int $index): ?int => $this->filterIndex($index, $max), $indices), + fn (?int $index): bool => null !== $index + ); + + return match (true) { + [] === $indices => $this, + count($indices) === $max => self::new(), + default => new self(array_filter( + $this->members, + fn (int $offset): bool => !in_array($offset, $indices, true), + ARRAY_FILTER_USE_KEY + ), $this->parameters), + }; + } + + /** + * @param int $offset + */ + public function offsetExists(mixed $offset): bool + { + return $this->hasIndices($offset); + } + + /** + * @param int $offset + */ + public function offsetGet(mixed $offset): Item + { + return $this->getByIndex($offset); + } + + public function offsetUnset(mixed $offset): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + public function offsetSet(mixed $offset, mixed $value): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + /** + * @param callable(Item, int): TMap $callback + * + * @template TMap + * + * @return Iterator<TMap> + */ + public function map(callable $callback): Iterator + { + foreach ($this->members as $offset => $member) { + yield ($callback)($member, $offset); + } + } + + /** + * @param callable(TInitial|null, Item, int=): TInitial $callback + * @param TInitial|null $initial + * + * @template TInitial + * + * @return TInitial|null + */ + public function reduce(callable $callback, mixed $initial = null): mixed + { + foreach ($this->members as $offset => $member) { + $initial = $callback($initial, $member, $offset); + } + + return $initial; + } + + /** + * @param callable(Item, int): bool $callback + */ + public function filter(callable $callback): self + { + $members = array_filter($this->members, $callback, ARRAY_FILTER_USE_BOTH); + if ($members === $this->members) { + return $this; + } + + return new self($members, $this->parameters); + } + + /** + * @param callable(Item, Item): int $callback + */ + public function sort(callable $callback): self + { + $members = $this->members; + uasort($members, $callback); + + return new self($members, $this->parameters); + } +} diff --git a/vendor/bakame/http-structured-fields/src/InvalidArgument.php b/vendor/bakame/http-structured-fields/src/InvalidArgument.php new file mode 100644 index 000000000..6c7c3344f --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/InvalidArgument.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use InvalidArgumentException; + +final class InvalidArgument extends InvalidArgumentException implements StructuredFieldError +{ +} diff --git a/vendor/bakame/http-structured-fields/src/InvalidOffset.php b/vendor/bakame/http-structured-fields/src/InvalidOffset.php new file mode 100644 index 000000000..ab878d98d --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/InvalidOffset.php @@ -0,0 +1,38 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use OutOfBoundsException; + +final class InvalidOffset extends OutOfBoundsException implements StructuredFieldError +{ + private function __construct(string $message) + { + parent::__construct($message); + } + + public static function dueToIndexNotFound(string|int $index): self + { + if (is_string($index)) { + return new self('The member index can not be the string "'.$index.'".'); + } + + return new self('No member exists with the index "'.$index.'".'); + } + + public static function dueToKeyNotFound(string|int $key): self + { + if (is_int($key)) { + return new self('The member key can not be the integer "'.$key.'".'); + } + + return new self('No member exists with the key "'.$key.'".'); + } + + public static function dueToMemberNotFound(string|int $offset): self + { + return new self('No member exists with the '.(is_int($offset) ? 'index' : 'key').' "'.$offset.'".'); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Item.php b/vendor/bakame/http-structured-fields/src/Item.php new file mode 100644 index 000000000..6d0434ee5 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Item.php @@ -0,0 +1,502 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use BadMethodCallException; +use Bakame\Http\StructuredFields\Validation\Violation; +use DateTimeImmutable; +use DateTimeInterface; +use DateTimeZone; +use Exception; +use ReflectionMethod; +use Stringable; +use Throwable; +use TypeError; + +use function array_is_list; +use function count; +use function in_array; + +use const JSON_PRESERVE_ZERO_FRACTION; +use const PHP_ROUND_HALF_EVEN; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.3 + * + * @phpstan-import-type SfType from StructuredFieldProvider + * @phpstan-import-type SfItemInput from StructuredFieldProvider + * @phpstan-import-type SfItemPair from StructuredFieldProvider + * @phpstan-import-type SfTypeInput from StructuredFieldProvider + * + * @method static ?Item tryFromPair(array{0: SfItemInput, 1?: Parameters|iterable<array{0:string, 1:SfItemInput}>}|array<mixed> $pair) try to create a new instance from a Pair + * @method static ?Item tryFromRfc9651(Stringable|string $httpValue) try to create a new instance from a string using RFC9651 + * @method static ?Item tryFromRfc8941(Stringable|string $httpValue) try to create a new instance from a string using RFC8941 + * @method static ?Item tryFromHttpValue(Stringable|string $httpValue) try to create a new instance from a string + * @method static ?Item tryFromAssociative(Bytes|Token|DisplayString|DateTimeInterface|string|int|float|bool $value, StructuredFieldProvider|Parameters|iterable<string, SfItemInput> $parameters) try to create a new instance from a value and a parameters as associative construct + * @method static ?Item tryNew(mixed $value) try to create a new bare instance from a value + * @method static ?Item tryFromEncodedBytes(Stringable|string $value) try to create a new instance from an encoded byte sequence + * @method static ?Item tryFromDecodedBytes(Stringable|string $value) try to create a new instance from a decoded byte sequence + * @method static ?Item tryFromEncodedDisplayString(Stringable|string $value) try to create a new instance from an encoded display string + * @method static ?Item tryFromDecodedDisplayString(Stringable|string $value) try to create a new instance from a decoded display string + * @method static ?Item tryFromToken(Stringable|string $value) try to create a new instance from a token string + * @method static ?Item tryFromTimestamp(int $timestamp) try to create a new instance from a timestamp + * @method static ?Item tryFromDateFormat(string $format, string $datetime) try to create a new instance from a date format + * @method static ?Item tryFromDateString(string $datetime, DateTimeZone|string|null $timezone = null) try to create a new instance from a date string + * @method static ?Item tryFromDate(DateTimeInterface $datetime) try to create a new instance from a DateTimeInterface object + * @method static ?Item tryFromDecimal(int|float $value) try to create a new instance from a float + * @method static ?Item tryFromInteger(int|float $value) try to create a new instance from an integer + */ +final class Item +{ + use ParameterAccess; + + private readonly Token|Bytes|DisplayString|DateTimeImmutable|int|float|string|bool $value; + private readonly Parameters $parameters; + private readonly Type $type; + + private function __construct(Token|Bytes|DisplayString|DateTimeInterface|int|float|string|bool $value, ?Parameters $parameters = null) + { + if ($value instanceof DateTimeInterface && !$value instanceof DateTimeImmutable) { + $value = DateTimeImmutable::createFromInterface($value); + } + + $this->value = $value; + $this->parameters = $parameters ?? Parameters::new(); + $this->type = Type::fromVariable($value); + } + + /** + * @throws BadMethodCallException + */ + public static function __callStatic(string $name, array $arguments): ?self /* @phpstan-ignore-line */ + { + if (!str_starts_with($name, 'try')) { + throw new BadMethodCallException('The method "'.self::class.'::'.$name.'" does not exist.'); + } + + $namedConstructor = lcfirst(substr($name, strlen('try'))); + if (!method_exists(self::class, $namedConstructor)) { + throw new BadMethodCallException('The method "'.self::class.'::'.$name.'" does not exist.'); + } + + $method = new ReflectionMethod(self::class, $namedConstructor); + if (!$method->isPublic() || !$method->isStatic()) { + throw new BadMethodCallException('The method "'.self::class.'::'.$name.'" can not be accessed directly.'); + } + + try { + return self::$namedConstructor(...$arguments); /* @phpstan-ignore-line */ + } catch (Throwable) { /* @phpstan-ignore-line */ + return null; + } + } + + public static function fromRfc9651(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc9651); + } + + public static function fromRfc8941(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc8941); + } + + /** + * Returns a new instance from an HTTP Header or Trailer value string + * in compliance with a published RFC. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.3 + * + * @throws SyntaxError|Exception If the HTTP value can not be parsed + */ + public static function fromHttpValue(Stringable|string $httpValue, Ietf $rfc = Ietf::Rfc9651): self + { + return self::fromPair((new Parser($rfc))->parseItem($httpValue)); + } + + /** + * Returns a new instance from a value type and an iterable of key-value parameters. + * + * @param StructuredFieldProvider|Parameters|iterable<string, SfItemInput> $parameters + * + * @throws SyntaxError If the value or the parameters are not valid + */ + public static function fromAssociative( + Bytes|Token|DisplayString|DateTimeInterface|string|int|float|bool $value, + StructuredFieldProvider|Parameters|iterable $parameters + ): self { + if ($parameters instanceof StructuredFieldProvider) { + $parameters = $parameters->toStructuredField(); + if ($parameters instanceof Parameters) { + return new self($value, $parameters); + } + + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Parameters::class.'; '.$parameters::class.' given.'); + } + + if (!$parameters instanceof Parameters) { + return new self($value, Parameters::fromAssociative($parameters)); + } + + return new self($value, $parameters); + } + + /** + * @param array{0: SfItemInput, 1?: Parameters|iterable<array{0:string, 1:SfItemInput}>}|array<mixed> $pair + * + * @throws SyntaxError If the pair or its content is not valid. + */ + public static function fromPair(array $pair): self + { + $nbElements = count($pair); + if (!in_array($nbElements, [1, 2], true) || !array_is_list($pair)) { + throw new SyntaxError('The pair must be represented by an non-empty array as a list containing exactly 1 or 2 members.'); + } + + if (1 === $nbElements) { + return new self($pair[0]); + } + + if ($pair[1] instanceof StructuredFieldProvider) { + $pair[1] = $pair[1]->toStructuredField(); + if ($pair[1] instanceof Parameters) { + return new self($pair[0], Parameters::fromPairs($pair[1])); + } + + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Parameters::class.'; '.$pair[1]::class.' given.'); + } + + if (!$pair[1] instanceof Parameters) { + return new self($pair[0], Parameters::fromPairs($pair[1])); + } + + return new self($pair[0], $pair[1]); + } + + /** + * Returns a new bare instance from value. + * + * @param SfItemPair|SfItemInput $value + * + * @throws SyntaxError|TypeError If the value is not valid. + */ + public static function new(mixed $value): self + { + if (is_array($value)) { + return self::fromPair($value); + } + + return new self($value); /* @phpstan-ignore-line */ + } + + /** + * Returns a new instance from a string. + * + * @throws SyntaxError if the string is invalid + */ + public static function fromString(Stringable|string $value): self + { + return new self((string)$value); + } + + /** + * Returns a new instance from an encoded byte sequence and an iterable of key-value parameters. + * + * @throws SyntaxError if the sequence is invalid + */ + public static function fromEncodedBytes(Stringable|string $value): self + { + return new self(Bytes::fromEncoded($value)); + } + + /** + * Returns a new instance from a decoded byte sequence and an iterable of key-value parameters. + * + * @throws SyntaxError if the sequence is invalid + */ + public static function fromDecodedBytes(Stringable|string $value): self + { + return new self(Bytes::fromDecoded($value)); + } + + /** + * Returns a new instance from an encoded byte sequence and an iterable of key-value parameters. + * + * @throws SyntaxError if the sequence is invalid + */ + public static function fromEncodedDisplayString(Stringable|string $value): self + { + return new self(DisplayString::fromEncoded($value)); + } + + /** + * Returns a new instance from a decoded byte sequence and an iterable of key-value parameters. + * + * @throws SyntaxError if the sequence is invalid + */ + public static function fromDecodedDisplayString(Stringable|string $value): self + { + return new self(DisplayString::fromDecoded($value)); + } + + /** + * Returns a new instance from a Token and an iterable of key-value parameters. + * + * @throws SyntaxError if the token is invalid + */ + public static function fromToken(Stringable|string $value): self + { + return new self(Token::fromString($value)); + } + + /** + * Returns a new instance from a timestamp and an iterable of key-value parameters. + * + * @throws SyntaxError if the timestamp value is not supported + */ + public static function fromTimestamp(int $timestamp): self + { + return new self((new DateTimeImmutable())->setTimestamp($timestamp)); + } + + /** + * Returns a new instance from a date format its date string representation and an iterable of key-value parameters. + * + * @throws SyntaxError if the format is invalid + */ + public static function fromDateFormat(string $format, string $datetime): self + { + try { + $value = DateTimeImmutable::createFromFormat($format, $datetime); + } catch (Exception $exception) { + throw new SyntaxError('The date notation `'.$datetime.'` is incompatible with the date format `'.$format.'`.', 0, $exception); + } + + if (!$value instanceof DateTimeImmutable) { + throw new SyntaxError('The date notation `'.$datetime.'` is incompatible with the date format `'.$format.'`.'); + } + + return new self($value); + } + + /** + * Returns a new instance from a string parsable by DateTimeImmutable constructor, an optional timezone and an iterable of key-value parameters. + * + * @throws SyntaxError if the format is invalid + */ + public static function fromDateString(string $datetime, DateTimeZone|string|null $timezone = null): self + { + $timezone ??= date_default_timezone_get(); + if (!$timezone instanceof DateTimeZone) { + try { + $timezone = new DateTimeZone($timezone); + } catch (Throwable $exception) { + throw new SyntaxError('The timezone could not be instantiated.', 0, $exception); + } + } + + try { + return new self(new DateTimeImmutable($datetime, $timezone)); + } catch (Throwable $exception) { + throw new SyntaxError('Unable to create a '.DateTimeImmutable::class.' instance with the date notation `'.$datetime.'.`', 0, $exception); + } + } + + /** + * Returns a new instance from a DateTineInterface implementing object. + * + * @throws SyntaxError if the format is invalid + */ + public static function fromDate(DateTimeInterface $datetime): self + { + return new self($datetime); + } + + /** + * Returns a new instance from a float value. + * + * @throws SyntaxError if the format is invalid + */ + public static function fromDecimal(int|float $value): self + { + return new self((float)$value); + } + + /** + * Returns a new instance from an integer value. + * + * @throws SyntaxError if the format is invalid + */ + public static function fromInteger(int|float $value): self + { + return new self((int)$value); + } + + /** + * Returns a new instance for the boolean true type. + */ + public static function true(): self + { + return new self(true); + } + + /** + * Returns a new instance for the boolean false type. + */ + public static function false(): self + { + return new self(false); + } + + /** + * Returns the underlying value. + * If a validation rule is provided, an exception will be thrown + * if the validation rules does not return true. + * + * if the validation returns false then a default validation message will be return; otherwise the submitted message string will be returned as is. + * + * @param ?callable(SfType): (string|bool) $validate + * + * @throws Violation + */ + public function value(?callable $validate = null): Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool + { + if (null === $validate) { + return $this->value; + } + + $exceptionMessage = $validate($this->value); + if (true === $exceptionMessage) { + return $this->value; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The item value '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{value}' => $this->serialize()])); + } + + public function type(): Type + { + return $this->type; + } + + /** + * Serialize the Item value according to RFC8941. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.1 + */ + public function toHttpValue(Ietf $rfc = Ietf::Rfc9651): string + { + return $this->serialize($rfc).$this->parameters->toHttpValue($rfc); + } + + /** + * Serialize the Item value according to RFC8941. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.1 + */ + private function serialize(Ietf $rfc = Ietf::Rfc9651): string + { + return match (true) { + !$rfc->supports($this->type) => throw MissingFeature::dueToLackOfSupport($this->type, $rfc), + $this->value instanceof DateTimeImmutable => '@'.$this->value->getTimestamp(), + $this->value instanceof Token => $this->value->toString(), + $this->value instanceof Bytes => ':'.$this->value->encoded().':', + $this->value instanceof DisplayString => '%"'.$this->value->encoded().'"', + is_int($this->value) => (string) $this->value, + is_float($this->value) => (string) json_encode(round($this->value, 3, PHP_ROUND_HALF_EVEN), JSON_PRESERVE_ZERO_FRACTION), + $this->value, + false === $this->value => '?'.($this->value ? '1' : '0'), + default => '"'.preg_replace('/(["\\\])/', '\\\$1', $this->value).'"', + }; + } + + public function toRfc9651(): string + { + return $this->toHttpValue(Ietf::Rfc9651); + } + + public function toRfc8941(): string + { + return $this->toHttpValue(Ietf::Rfc8941); + } + + public function __toString(): string + { + return $this->toHttpValue(); + } + + /** + * @return array{0:SfItemInput, 1:Parameters} + */ + public function toPair(): array + { + return [$this->value, $this->parameters]; + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->toHttpValue() === $this->toHttpValue(); + } + + /** + * Apply the callback if the given "condition" is (or resolves to) true. + * + * @param (callable($this): bool)|bool $condition + * @param callable($this): (self|null) $onSuccess + * @param ?callable($this): (self|null) $onFail + */ + public function when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null): self + { + if (!is_bool($condition)) { + $condition = $condition($this); + } + + return match (true) { + $condition => $onSuccess($this), + null !== $onFail => $onFail($this), + default => $this, + } ?? $this; + } + + /** + * Returns a new instance with the newly associated value. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified value change. + * + * @throws SyntaxError If the value is invalid or not supported + */ + public function withValue(DateTimeInterface|Bytes|Token|DisplayString|string|int|float|bool $value): self + { + $isEqual = match (true) { + $this->value instanceof Bytes, + $this->value instanceof Token, + $this->value instanceof DisplayString => $this->value->equals($value), + $this->value instanceof DateTimeInterface && $value instanceof DateTimeInterface => $value->getTimestamp() === $this->value->getTimestamp(), + default => $value === $this->value, + }; + + if ($isEqual) { + return $this; + } + + return new self($value, $this->parameters); + } + + public function withParameters(StructuredFieldProvider|Parameters $parameters): static + { + if ($parameters instanceof StructuredFieldProvider) { + $parameters = $parameters->toStructuredField(); + if (!$parameters instanceof Parameters) { + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Parameters::class.'; '.$parameters::class.' given.'); + } + } + + return $this->parameters->equals($parameters) ? $this : new self($this->value, $parameters); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Key.php b/vendor/bakame/http-structured-fields/src/Key.php new file mode 100644 index 000000000..e1971426a --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Key.php @@ -0,0 +1,53 @@ +<?php + +namespace Bakame\Http\StructuredFields; + +use Stringable; + +use function preg_match; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.2 + * @internal normalize HTTP field key + */ +final class Key +{ + private function __construct(public readonly string $value) + { + } + + /** + * @throws SyntaxError If the string is not a valid HTTP value field key + */ + public static function from(Stringable|string|int $httpValue): self + { + $key = (string) $httpValue; + $instance = self::fromStringBeginning($key); + if ($instance->value !== $key) { + throw new SyntaxError('No valid http value key could be extracted from "'.$httpValue.'".'); + } + + return $instance; + } + + public static function tryFrom(Stringable|string|int $httpValue): ?self + { + try { + return self::from($httpValue); + } catch (SyntaxError $e) { + return null; + } + } + + /** + * @throws SyntaxError If the string does not start with a valid HTTP value field key + */ + public static function fromStringBeginning(string $httpValue): self + { + if (1 !== preg_match('/^(?<key>[a-z*][a-z\d.*_-]*)/', $httpValue, $found)) { + throw new SyntaxError('No valid http value key could be extracted from "'.$httpValue.'".'); + } + + return new self($found['key']); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Member.php b/vendor/bakame/http-structured-fields/src/Member.php new file mode 100644 index 000000000..ee315b078 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Member.php @@ -0,0 +1,116 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use function count; +use function in_array; +use function is_array; +use function is_iterable; + +/** + * @phpstan-import-type SfMemberInput from StructuredFieldProvider + * @phpstan-import-type SfItemInput from StructuredFieldProvider + * @phpstan-import-type SfItemPair from StructuredFieldProvider + * @phpstan-import-type SfInnerListPair from StructuredFieldProvider + * @phpstan-import-type SfTypeInput from StructuredFieldProvider + * + * @internal Validate containers member + */ +final class Member +{ + /** + * @param SfMemberInput $value + */ + public static function innerListOrItem(mixed $value): InnerList|Item + { + if ($value instanceof StructuredFieldProvider) { + $value = $value->toStructuredField(); + if ($value instanceof Item || $value instanceof InnerList) { + return $value; + } + + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Item::class.' or an '.InnerList::class.'; '.$value::class.' given.'); + } + + return match (true) { + $value instanceof InnerList, + $value instanceof Item => $value, + is_iterable($value) => InnerList::new(...$value), + default => Item::new($value), + }; + } + + public static function innerListOrItemFromPair(mixed $value): InnerList|Item + { + if ($value instanceof StructuredFieldProvider) { + $value = $value->toStructuredField(); + if ($value instanceof Item || $value instanceof InnerList) { + return $value; + } + + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Item::class.' or an '.InnerList::class.'; '.$value::class.' given.'); + } + + if ($value instanceof InnerList || $value instanceof Item) { + return $value; + } + + if (!is_array($value)) { + if (is_iterable($value)) { + throw new SyntaxError('The value must be an Item value not an iterable.'); + } + + return Item::new($value); /* @phpstan-ignore-line */ + } + + if (!array_is_list($value)) { + throw new SyntaxError('The pair must be represented by an array as a list.'); + } + + if ([] === $value) { + return InnerList::new(); + } + + if (!in_array(count($value), [1, 2], true)) { + throw new SyntaxError('The pair first member represents its value; the second member is its associated parameters.'); + } + + return is_iterable($value[0]) ? InnerList::fromPair($value) : Item::fromPair($value); + } + + /** + * @param SfItemInput|SfItemPair $value + */ + public static function item(mixed $value): Item + { + if ($value instanceof StructuredFieldProvider) { + $value = $value->toStructuredField(); + if (!$value instanceof Item) { + throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a '.Item::class.'; '.$value::class.' given.'); + } + + return $value; + } + + if ($value instanceof Item) { + return $value; + } + + return Item::new($value); + } + + /** + * @param SfItemInput|SfItemPair $value + */ + public static function bareItem(mixed $value): Item + { + $bareItem = self::item($value); + if ($bareItem->parameters()->isNotEmpty()) { + throw new InvalidArgument('The "'.$bareItem::class.'" instance is not a Bare Item.'); + } + + return $bareItem; + } +} diff --git a/vendor/bakame/http-structured-fields/src/MissingFeature.php b/vendor/bakame/http-structured-fields/src/MissingFeature.php new file mode 100644 index 000000000..03bd8c05f --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/MissingFeature.php @@ -0,0 +1,13 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +final class MissingFeature extends SyntaxError +{ + public static function dueToLackOfSupport(Type $type, Ietf $rfc): self + { + return new self('The \''.$type->value.'\' type is not handled by '.strtoupper($rfc->name)); + } +} diff --git a/vendor/bakame/http-structured-fields/src/OuterList.php b/vendor/bakame/http-structured-fields/src/OuterList.php new file mode 100644 index 000000000..644f1990e --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/OuterList.php @@ -0,0 +1,430 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use ArrayAccess; +use Bakame\Http\StructuredFields\Validation\Violation; +use Countable; +use DateTimeInterface; +use Exception; +use Iterator; +use IteratorAggregate; +use Stringable; + +use function array_filter; +use function array_map; +use function array_replace; +use function array_splice; +use function array_values; +use function count; +use function implode; +use function is_iterable; +use function uasort; + +use const ARRAY_FILTER_USE_BOTH; +use const ARRAY_FILTER_USE_KEY; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#name-lists + * + * @phpstan-import-type SfMemberInput from StructuredFieldProvider + * @phpstan-import-type SfInnerListPair from StructuredFieldProvider + * @phpstan-import-type SfItemPair from StructuredFieldProvider + * + * @implements ArrayAccess<int, InnerList|Item> + * @implements IteratorAggregate<int, InnerList|Item> + */ +final class OuterList implements ArrayAccess, Countable, IteratorAggregate +{ + /** @var list<InnerList|Item> */ + private readonly array $members; + + /** + * @param SfMemberInput ...$members + */ + private function __construct( + iterable|StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ) { + $this->members = array_map(Member::innerListOrItem(...), array_values([...$members])); + } + + /** + * Returns an instance from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1 + * + * @throws SyntaxError|Exception + */ + public static function fromHttpValue(Stringable|string $httpValue, Ietf $rfc = Ietf::Rfc9651): self + { + return self::fromPairs((new Parser($rfc))->parseList($httpValue)); /* @phpstan-ignore-line */ + } + + /** + * @param StructuredFieldProvider|iterable<SfInnerListPair|SfItemPair> $pairs + */ + public static function fromPairs(StructuredFieldProvider|iterable $pairs): self + { + if ($pairs instanceof StructuredFieldProvider) { + $pairs = $pairs->toStructuredField(); + } + + if (!is_iterable($pairs)) { + throw new InvalidArgument('The "'.$pairs::class.'" instance can not be used for creating a .'.self::class.' structured field.'); + } + + return match (true) { + $pairs instanceof OuterList, + $pairs instanceof InnerList => new self($pairs), + default => new self(...(function (iterable $pairs) { + foreach ($pairs as $member) { + yield Member::innerListOrItemFromPair($member); + } + })($pairs)), + }; + } + + /** + * @param StructuredFieldProvider|SfInnerListPair|SfItemPair|SfMemberInput ...$members + */ + public static function new(iterable|StructuredFieldProvider|InnerList|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members): self + { + return self::fromPairs($members); /* @phpstan-ignore-line*/ + } + + public static function fromRfc9651(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc9651); + } + + public static function fromRfc8941(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc8941); + } + + public function toHttpValue(Ietf $rfc = Ietf::Rfc9651): string + { + return implode(', ', array_map(fn (Item|InnerList $member): string => $member->toHttpValue($rfc), $this->members)); + } + + public function toRfc9651(): string + { + return $this->toHttpValue(Ietf::Rfc9651); + } + + public function toRfc8941(): string + { + return $this->toHttpValue(Ietf::Rfc8941); + } + + public function __toString(): string + { + return $this->toHttpValue(); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->toHttpValue() === $this->toHttpValue(); + } + + /** + * Apply the callback if the given "condition" is (or resolves to) true. + * + * @param (callable($this): bool)|bool $condition + * @param callable($this): (self|null) $onSuccess + * @param ?callable($this): (self|null) $onFail + */ + public function when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null): self + { + if (!is_bool($condition)) { + $condition = $condition($this); + } + + return match (true) { + $condition => $onSuccess($this), + null !== $onFail => $onFail($this), + default => $this, + } ?? $this; + } + + public function getIterator(): Iterator + { + yield from $this->members; + } + + public function count(): int + { + return count($this->members); + } + + public function isEmpty(): bool + { + return !$this->isNotEmpty(); + } + + public function isNotEmpty(): bool + { + return [] !== $this->members; + } + + /** + * @return array<int> + */ + public function indices(): array + { + return array_keys($this->members); + } + + public function hasIndices(int ...$indices): bool + { + $max = count($this->members); + foreach ($indices as $index) { + if (null === $this->filterIndex($index, $max)) { + return false; + } + } + + return [] !== $indices; + } + + private function filterIndex(int $index, ?int $max = null): ?int + { + $max ??= count($this->members); + + return match (true) { + [] === $this->members, + 0 > $max + $index, + 0 > $max - $index - 1 => null, + 0 > $index => $max + $index, + default => $index, + }; + } + + /** + * @param ?callable(InnerList|Item): (bool|string) $validate + * + * @throws SyntaxError|Violation|StructuredFieldError + */ + public function getByIndex(int $index, ?callable $validate = null): InnerList|Item + { + $value = $this->members[$this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index)]; + if (null === $validate) { + return $value; + } + + if (true === ($exceptionMessage = $validate($value))) { + return $value; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The member at position '{index}' whose value is '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{index}' => $index, '{value}' => $value->toHttpValue()])); + } + + public function first(): InnerList|Item|null + { + return $this->members[0] ?? null; + } + + public function last(): InnerList|Item|null + { + return $this->members[$this->filterIndex(-1)] ?? null; + } + + /** + * Inserts members at the beginning of the list. + * + * @param SfMemberInput ...$members + */ + public function unshift( + StructuredFieldProvider|InnerList|Item|iterable|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ): self { + $membersToAdd = array_reduce( + $members, + function (array $carry, $member) { + if ($member instanceof StructuredFieldProvider) { + $member = $member->toStructuredField(); + } + + return [...$carry, ...$member instanceof InnerList ? [...$member] : [$member]]; + }, + [] + ); + + return match (true) { + [] === $membersToAdd => $this, + default => new self(...array_values($membersToAdd), ...$this->members), + }; + } + + /** + * Inserts members at the end of the list. + * + * @param SfMemberInput ...$members + */ + public function push( + iterable|StructuredFieldProvider|InnerList|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ): self { + $membersToAdd = array_reduce( + $members, + function (array $carry, $member) { + if ($member instanceof StructuredFieldProvider) { + $member = $member->toStructuredField(); + } + + return [...$carry, ...$member instanceof InnerList ? [...$member] : [$member]]; + }, + [] + ); + + return match (true) { + [] === $membersToAdd => $this, + default => new self(...$this->members, ...array_values($membersToAdd)), + }; + } + + /** + * Inserts members starting at the given index. + * + * @param SfMemberInput ...$members + * + * @throws InvalidOffset If the index does not exist + */ + public function insert( + int $index, + iterable|StructuredFieldProvider|InnerList|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool ...$members + ): self { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + + return match (true) { + 0 === $offset => $this->unshift(...$members), + count($this->members) === $offset => $this->push(...$members), + [] === $members => $this, + default => (function (array $newMembers) use ($offset, $members) { + array_splice($newMembers, $offset, 0, $members); + + return new self(...$newMembers); + })($this->members), + }; + } + + /** + * @param SfMemberInput $member + */ + public function replace( + int $index, + iterable|StructuredFieldProvider|InnerList|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + $member = Member::innerListOrItem($member); + + return match (true) { + $member->equals($this->members[$offset]) => $this, + default => new self(...array_replace($this->members, [$offset => $member])), + }; + } + + public function removeByIndices(int ...$indices): self + { + $max = count($this->members); + $offsets = array_filter( + array_map(fn (int $index): ?int => $this->filterIndex($index, $max), $indices), + fn (?int $index): bool => null !== $index + ); + + return match (true) { + [] === $offsets => $this, + $max === count($offsets) => new self(), + default => new self(...array_filter( + $this->members, + fn (int $index): bool => !in_array($index, $offsets, true), + ARRAY_FILTER_USE_KEY + )), + }; + } + + /** + * @param int $offset + */ + public function offsetExists(mixed $offset): bool + { + return $this->hasIndices($offset); + } + + /** + * @param int $offset + */ + public function offsetGet(mixed $offset): InnerList|Item + { + return $this->getByIndex($offset); + } + + public function offsetUnset(mixed $offset): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + public function offsetSet(mixed $offset, mixed $value): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + /** + * @param callable(InnerList|Item, int): TMap $callback + * + * @template TMap + * + * @return Iterator<TMap> + */ + public function map(callable $callback): Iterator + { + foreach ($this->members as $offset => $member) { + yield ($callback)($member, $offset); + } + } + + /** + * @param callable(TInitial|null, InnerList|Item, int): TInitial $callback + * @param TInitial|null $initial + * + * @template TInitial + * + * @return TInitial|null + */ + public function reduce(callable $callback, mixed $initial = null): mixed + { + foreach ($this->members as $offset => $member) { + $initial = $callback($initial, $member, $offset); + } + + return $initial; + } + + /** + * @param callable(InnerList|Item, int): bool $callback + */ + public function filter(callable $callback): self + { + $members = array_filter($this->members, $callback, ARRAY_FILTER_USE_BOTH); + if ($members === $this->members) { + return $this; + } + + return new self(...$members); + } + + /** + * @param callable(InnerList|Item, InnerList|Item): int $callback + */ + public function sort(callable $callback): self + { + $members = $this->members; + uasort($members, $callback); + + return new self(...$members); + } +} diff --git a/vendor/bakame/http-structured-fields/src/ParameterAccess.php b/vendor/bakame/http-structured-fields/src/ParameterAccess.php new file mode 100644 index 000000000..9c71f0955 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/ParameterAccess.php @@ -0,0 +1,260 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use Bakame\Http\StructuredFields\Validation\Violation; +use DateTimeImmutable; +use DateTimeInterface; + +/** + * Common manipulation methods used when interacting with an object + * with a Parameters instance attached to it. + * + * @phpstan-import-type SfType from StructuredFieldProvider + * @phpstan-import-type SfItemInput from StructuredFieldProvider + */ +trait ParameterAccess +{ + /** + * Returns a copy of the associated parameter instance. + */ + public function parameters(): Parameters + { + return $this->parameters; + } + + /** + * Returns the member value or null if no members value exists. + * + * @param ?callable(SfType): (bool|string) $validate + * + * @throws Violation if the validation fails + * + * @return SfType|null + */ + public function parameterByKey( + string $key, + ?callable $validate = null, + bool|string $required = false, + Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool|null $default = null + ): Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool|null { + return $this->parameters->valueByKey($key, $validate, $required, $default); + } + + /** + * Returns the member value and key as pair or an empty array if no members value exists. + * + * @param ?callable(SfType, string): (bool|string) $validate + * @param array{0:string, 1:SfType}|array{} $default + * + * @throws Violation if the validation fails + * + * @return array{0:string, 1:SfType}|array{} + */ + public function parameterByIndex( + int $index, + ?callable $validate = null, + bool|string $required = false, + array $default = [] + ): array { + return $this->parameters->valueByIndex($index, $validate, $required, $default); + } + + /** + * Returns a new instance with the newly associated parameter instance. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + */ + abstract public function withParameters(Parameters $parameters): static; + + /** + * Adds a member if its key is not present at the of the associated parameter instance or update the instance at the given key. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param StructuredFieldProvider|Item|SfType $member + * + * @throws SyntaxError If the string key is not a valid + */ + public function addParameter( + string $key, + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): static { + return $this->withParameters($this->parameters()->add($key, $member)); + } + + /** + * Adds a member at the start of the associated parameter instance and deletes any previous reference to the key if present. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param StructuredFieldProvider|Item|SfType $member + * + * @throws SyntaxError If the string key is not a valid + */ + public function prependParameter( + string $key, + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): static { + return $this->withParameters($this->parameters()->prepend($key, $member)); + } + + /** + * Adds a member at the end of the associated parameter instance and deletes any previous reference to the key if present. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param StructuredFieldProvider|Item|SfType $member + * + * @throws SyntaxError If the string key is not a valid + */ + public function appendParameter( + string $key, + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): static { + return $this->withParameters($this->parameters()->append($key, $member)); + } + + /** + * Removes all parameters members associated with the list of submitted keys in the associated parameter instance. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + */ + public function withoutAnyParameter(): static + { + return $this->withParameters(Parameters::new()); + } + + /** + * Inserts pair at the end of the member list. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param array{0:string, 1:SfItemInput} ...$pairs + */ + public function pushParameters(array ...$pairs): static + { + return $this->withParameters($this->parameters()->push(...$pairs)); + } + + /** + * Inserts pair at the beginning of the member list. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param array{0:string, 1:SfItemInput} ...$pairs + */ + public function unshiftParameters(array ...$pairs): static + { + return $this->withParameters($this->parameters()->unshift(...$pairs)); + } + + /** + * Delete member based on their key. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + */ + public function withoutParameterByKeys(string ...$keys): static + { + return $this->withParameters($this->parameters()->removeByKeys(...$keys)); + } + + /** + * Delete member based on their offsets. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + */ + public function withoutParameterByIndices(int ...$indices): static + { + return $this->withParameters($this->parameters()->removeByIndices(...$indices)); + } + + /** + * Inserts members at the specified index. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param array{0:string, 1:SfType} ...$pairs + */ + public function insertParameters(int $index, array ...$pairs): static + { + return $this->withParameters($this->parameters()->insert($index, ...$pairs)); + } + + /** + * Replace the member at the specified index. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param array{0:string, 1:SfType} $pair + */ + public function replaceParameter(int $index, array $pair): static + { + return $this->withParameters($this->parameters()->replace($index, $pair)); + } + + /** + * Sort the object parameters by value using a callback. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param callable(array{0:string, 1:Item}, array{0:string, 1:Item}): int $callback + */ + public function sortParameters(callable $callback): static + { + return $this->withParameters($this->parameters()->sort($callback)); + } + + /** + * Filter the object parameters using a callback. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified parameter change. + * + * @param callable(array{0:string, 1:Item}, int): bool $callback + */ + public function filterParameters(callable $callback): static + { + return $this->withParameters($this->parameters()->filter($callback)); + } + + /** + * Merges multiple instances using iterable pairs. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param StructuredFieldProvider|Parameters|Dictionary|iterable<array{0:string, 1:SfItemInput}> ...$others + */ + public function mergeParametersByPairs(...$others): static + { + return $this->withParameters($this->parameters()->mergePairs(...$others)); + } + + /** + * Merges multiple instances using iterable associative. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified changes. + * + * @param StructuredFieldProvider|Dictionary|Parameters|iterable<string, SfItemInput> ...$others + */ + public function mergeParametersByAssociative(...$others): static + { + return $this->withParameters($this->parameters()->mergeAssociative(...$others)); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Parameters.php b/vendor/bakame/http-structured-fields/src/Parameters.php new file mode 100644 index 000000000..9fd9a4e2b --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Parameters.php @@ -0,0 +1,763 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use ArrayAccess; +use Bakame\Http\StructuredFields\Validation\Violation; +use CallbackFilterIterator; +use Countable; +use DateTimeImmutable; +use DateTimeInterface; +use Exception; +use Iterator; +use IteratorAggregate; +use Stringable; + +use function array_key_exists; +use function array_keys; +use function array_map; +use function array_replace; +use function count; +use function implode; +use function is_int; +use function is_string; +use function trim; +use function uasort; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.2 + * + * @phpstan-import-type SfItemInput from StructuredFieldProvider + * @phpstan-import-type SfType from StructuredFieldProvider + * + * @implements ArrayAccess<string, Item> + * @implements IteratorAggregate<int, array{0:string, 1:Item}> + */ +final class Parameters implements ArrayAccess, Countable, IteratorAggregate +{ + /** @var array<string, Item> */ + private readonly array $members; + + /** + * @param iterable<string, SfItemInput> $members + */ + private function __construct(iterable $members = []) + { + $filteredMembers = []; + foreach ($members as $key => $member) { + $filteredMembers[Key::from($key)->value] = Member::bareItem($member); + } + + $this->members = $filteredMembers; + } + + /** + * Returns a new instance. + */ + public static function new(): self + { + return new self(); + } + + /** + * Returns a new instance from an associative iterable construct. + * + * its keys represent the dictionary entry key + * its values represent the dictionary entry value + * + * @param StructuredFieldProvider|iterable<string, SfItemInput> $members + */ + public static function fromAssociative(StructuredFieldProvider|iterable $members): self + { + if ($members instanceof StructuredFieldProvider) { + $structuredField = $members->toStructuredField(); + + return match (true) { + $structuredField instanceof Dictionary, + $structuredField instanceof Parameters => new self($structuredField->toAssociative()), + default => throw new InvalidArgument('The '.StructuredFieldProvider::class.' must provide a structured field container; '.$structuredField::class.' given.'), + }; + } + + return new self($members); + } + + /** + * Returns a new instance from a pair iterable construct. + * + * Each member is composed of an array with two elements + * the first member represents the instance entry key + * the second member represents the instance entry value + * + * @param StructuredFieldProvider|iterable<array{0:string, 1:SfItemInput}> $pairs + */ + public static function fromPairs(StructuredFieldProvider|iterable $pairs): self + { + if ($pairs instanceof StructuredFieldProvider) { + $pairs = $pairs->toStructuredField(); + } + + if (!is_iterable($pairs)) { + throw new InvalidArgument('The "'.$pairs::class.'" instance can not be used for creating a .'.self::class.' structured field.'); + } + + return match (true) { + $pairs instanceof Parameters, + $pairs instanceof Dictionary => new self($pairs->toAssociative()), + default => new self((function (iterable $pairs) { + foreach ($pairs as [$key, $member]) { + yield $key => $member; + } + })($pairs)), + }; + } + + /** + * Returns an instance from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.2 + * + * @throws SyntaxError|Exception If the string is not a valid + */ + public static function fromHttpValue(Stringable|string $httpValue, Ietf $rfc = Ietf::Rfc9651): self + { + return self::fromPairs((new Parser($rfc))->parseParameters($httpValue)); /* @phpstan-ignore-line */ + } + + public static function fromRfc9651(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc9651); + } + + public static function fromRfc8941(Stringable|string $httpValue): self + { + return self::fromHttpValue($httpValue, Ietf::Rfc8941); + } + + public function toHttpValue(Ietf $rfc = Ietf::Rfc9651): string + { + $formatter = static fn (Item $member, string $offset): string => match ($member->value()) { + true => ';'.$offset, + default => ';'.$offset.'='.$member->toHttpValue($rfc), + }; + + return implode('', array_map($formatter, $this->members, array_keys($this->members))); + } + + public function toRfc9651(): string + { + return $this->toHttpValue(Ietf::Rfc9651); + } + + public function toRfc8941(): string + { + return $this->toHttpValue(Ietf::Rfc8941); + } + + public function __toString(): string + { + return $this->toHttpValue(); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->toHttpValue() === $this->toHttpValue(); + } + + /** + * Apply the callback if the given "condition" is (or resolves to) true. + * + * @param (callable($this): bool)|bool $condition + * @param callable($this): (self|null) $onSuccess + * @param ?callable($this): (self|null) $onFail + */ + public function when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null): self + { + if (!is_bool($condition)) { + $condition = $condition($this); + } + + return match (true) { + $condition => $onSuccess($this), + null !== $onFail => $onFail($this), + default => $this, + } ?? $this; + } + + public function count(): int + { + return count($this->members); + } + + public function isEmpty(): bool + { + return !$this->isNotEmpty(); + } + + public function isNotEmpty(): bool + { + return [] !== $this->members; + } + + /** + * @return Iterator<string, Item> + */ + public function toAssociative(): Iterator + { + yield from $this->members; + } + + /** + * @return Iterator<int, array{0:string, 1:Item}> + */ + public function getIterator(): Iterator + { + foreach ($this->members as $index => $member) { + yield [$index, $member]; + } + } + + /** + * @return array<string> + */ + public function keys(): array + { + return array_keys($this->members); + } + + /** + * Tells whether the instance contain a members at the specified offsets. + */ + public function hasKeys(string ...$keys): bool + { + foreach ($keys as $key) { + if (!array_key_exists($key, $this->members)) { + return false; + } + } + + return [] !== $keys; + } + + /** + * @param ?callable(SfType): (bool|string) $validate + * + * @throws Violation|InvalidOffset + */ + public function getByKey(string $key, ?callable $validate = null): Item + { + $value = $this->members[$key] ?? throw InvalidOffset::dueToKeyNotFound($key); + if (null === $validate || true === ($exceptionMessage = $validate($value->value()))) { + return $value; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The parameter '{key}' whose value is '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{key}' => $key, '{value}' => $value->toHttpValue()])); + } + + /** + * @return array<int> + */ + public function indices(): array + { + return array_keys($this->keys()); + } + + public function hasIndices(int ...$indices): bool + { + $max = count($this->members); + foreach ($indices as $index) { + if (null === $this->filterIndex($index, $max)) { + return false; + } + } + + return [] !== $indices; + } + + /** + * Filters and format instance index. + */ + private function filterIndex(int $index, int|null $max = null): int|null + { + $max ??= count($this->members); + + return match (true) { + [] === $this->members, + 0 > $max + $index, + 0 > $max - $index - 1 => null, + 0 > $index => $max + $index, + default => $index, + }; + } + + /** + * @param ?callable(SfType, string): (bool|string) $validate + * + * @throws InvalidOffset|Violation + * + * @return array{0:string, 1:Item} + */ + public function getByIndex(int $index, ?callable $validate = null): array + { + $foundOffset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + foreach ($this as $offset => $pair) { + if ($offset === $foundOffset) { + break; + } + } + + if (!isset($pair)) { + throw InvalidOffset::dueToIndexNotFound($index); + } + + if (null === $validate || true === ($exceptionMessage = $validate($pair[1]->value(), $pair[0]))) { + return $pair; + } + + if (!is_string($exceptionMessage) || '' === trim($exceptionMessage)) { + $exceptionMessage = "The parameter at position '{index}' whose key is '{key}' with the value '{value}' failed validation."; + } + + throw new Violation(strtr($exceptionMessage, ['{index}' => $index, '{key}' => $pair[0], '{value}' => $pair[1]->toHttpValue()])); + } + + /** + * Returns the key associated with the given index or null otherwise. + */ + public function indexByKey(string $key): ?int + { + foreach ($this as $index => $member) { + if ($key === $member[0]) { + return $index; + } + } + + return null; + } + + /** + * Returns the index associated with the given key or null otherwise. + */ + public function keyByIndex(int $index): ?string + { + $index = $this->filterIndex($index); + if (null === $index) { + return null; + } + + foreach ($this as $offset => $member) { + if ($offset === $index) { + return $member[0]; + } + } + + return null; + } + + /** + * @return array{0:string, 1:Item}|array{} + */ + public function first(): array + { + try { + return $this->getByIndex(0); + } catch (InvalidOffset) { + return []; + } + } + + /** + * @return array{0:string, 1:Item}|array{} + */ + public function last(): array + { + try { + return $this->getByIndex(-1); + } catch (InvalidOffset) { + return []; + } + } + + /** + * Returns true only if the instance only contains the listed keys, false otherwise. + * + * @param array<string> $keys + */ + public function allowedKeys(array $keys): bool + { + foreach ($this->members as $key => $member) { + if (!in_array($key, $keys, true)) { + return false; + } + } + + return [] !== $keys; + } + + /** + * Returns the member value or null if no members value exists. + * + * @param ?callable(SfType): (bool|string) $validate + * + * @throws Violation if the validation fails + * + * @return SfType|null + */ + public function valueByKey( + string $key, + ?callable $validate = null, + bool|string $required = false, + Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool|null $default = null + ): Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool|null { + if (null !== $default && null === Type::tryFromVariable($default)) { + throw new SyntaxError('The default parameter is invalid.'); + } + + try { + return $this->getByKey($key, $validate)->value(); + } catch (InvalidOffset $exception) { + if (false === $required) { + return $default; + } + + $message = $required; + if (!is_string($message) || '' === trim($message)) { + $message = "The required parameter '{key}' is missing."; + } + + throw new Violation(strtr($message, ['{key}' => $key]), previous: $exception); + } + } + + /** + * Returns the member value and key as pair or an empty array if no members value exists. + * + * @param ?callable(SfType, string): (bool|string) $validate + * @param array{0:string, 1:SfType}|array{} $default + * + * @throws Violation if the validation fails + * + * @return array{0:string, 1:SfType}|array{} + */ + public function valueByIndex(int $index, ?callable $validate = null, bool|string $required = false, array $default = []): array + { + $default = match (true) { + [] === $default => [], + !array_is_list($default) => throw new SyntaxError('The pair must be represented by an array as a list.'), /* @phpstan-ignore-line */ + 2 !== count($default) => throw new SyntaxError('The pair first member is the key; its second member is its value.'), /* @phpstan-ignore-line */ + null === ($key = Key::tryFrom($default[0])?->value) => throw new SyntaxError('The pair first member is invalid.'), + null === ($value = Item::tryNew($default[1])?->value()) => throw new SyntaxError('The pair second member is invalid.'), + default => [$key, $value], + }; + + try { + $tuple = $this->getByIndex($index, $validate); + + return [$tuple[0], $tuple[1]->value()]; + } catch (InvalidOffset $exception) { + if (false === $required) { + return $default; + } + + $message = $required; + if (!is_string($message) || '' === trim($message)) { + $message = "The required parameter at position '{index}' is missing."; + } + + throw new Violation(strtr($message, ['{index}' => $index]), previous: $exception); + } + } + + /** + * @param StructuredFieldProvider|Item|SfType $member + */ + public function add( + string $key, + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $key = Key::from($key)->value; + $member = Member::bareItem($member); + $oldMember = $this->members[$key] ?? null; + if (null === $oldMember || !$oldMember->equals($member)) { + $members = $this->members; + $members[$key] = $member; + + return new self($members); + } + + return $this; + } + + /** + * @param array<string, Item> $members + */ + private function newInstance(array $members): self + { + foreach ($members as $offset => $member) { + if (!isset($this->members[$offset]) || !$this->members[$offset]->equals($member)) { + return new self($members); + } + } + + return $this; + } + + private function remove(string|int ...$offsets): self + { + if ([] === $this->members || [] === $offsets) { + return $this; + } + + $keys = array_keys($this->members); + $max = count($keys); + $reducer = fn (array $carry, string|int $key): array => match (true) { + is_string($key) && (false !== ($position = array_search($key, $keys, true))), + is_int($key) && (null !== ($position = $this->filterIndex($key, $max))) => [$position => true] + $carry, + default => $carry, + }; + + $indices = array_reduce($offsets, $reducer, []); + + return match (true) { + [] === $indices => $this, + $max === count($indices) => self::new(), + default => self::fromPairs((function (array $offsets) { + foreach ($this as $offset => $pair) { + if (!array_key_exists($offset, $offsets)) { + yield $pair; + } + } + })($indices)), + }; + } + + public function removeByIndices(int ...$indices): self + { + return $this->remove(...$indices); + } + + public function removeByKeys(string ...$keys): self + { + return $this->remove(...$keys); + } + + /** + * @param StructuredFieldProvider|Item|SfType $member + */ + public function append( + string $key, + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $key = Key::from($key)->value; + $member = Member::bareItem($member); + $members = $this->members; + unset($members[$key]); + $members[$key] = $member; + + return $this->newInstance($members); + } + + /** + * @param StructuredFieldProvider|Item|SfType $member + */ + public function prepend( + string $key, + StructuredFieldProvider|Item|Token|Bytes|DisplayString|DateTimeInterface|string|int|float|bool $member + ): self { + $key = Key::from($key)->value; + $member = Member::bareItem($member); + $members = $this->members; + unset($members[$key]); + + return $this->newInstance([$key => $member, ...$members]); + } + + /** + * @param array{0:string, 1:SfItemInput} ...$pairs + */ + public function push(array ...$pairs): self + { + return match (true) { + [] === $pairs => $this, + default => self::fromPairs((function (iterable $pairs) { + yield from $this->getIterator(); + yield from $pairs; + })($pairs)), + }; + } + + /** + * @param array{0:string, 1:SfItemInput} ...$pairs + */ + public function unshift(array ...$pairs): self + { + return match (true) { + [] === $pairs => $this, + default => self::fromPairs((function (iterable $pairs) { + yield from $pairs; + yield from $this->getIterator(); + })($pairs)), + }; + } + + /** + * @param array{0:string, 1:SfItemInput} ...$members + */ + public function insert(int $index, array ...$members): self + { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + + return match (true) { + [] === $members => $this, + 0 === $offset => $this->unshift(...$members), + count($this->members) === $offset => $this->push(...$members), + default => (function (Iterator $newMembers) use ($offset, $members) { + $newMembers = iterator_to_array($newMembers); + array_splice($newMembers, $offset, 0, $members); + + return self::fromPairs($newMembers); + })($this->getIterator()), + }; + } + + /** + * @param array{0:string, 1:SfItemInput} $pair + */ + public function replace(int $index, array $pair): self + { + $offset = $this->filterIndex($index) ?? throw InvalidOffset::dueToIndexNotFound($index); + $pair[1] = Member::bareItem($pair[1]); + $pairs = iterator_to_array($this); + + return match (true) { + $pairs[$offset][0] === $pair[0] && $pairs[$offset][1]->equals($pair[1]) => $this, + default => self::fromPairs(array_replace($pairs, [$offset => $pair])), + }; + } + + /** + * @param StructuredFieldProvider|Dictionary|Parameters|iterable<string, SfItemInput> ...$others + */ + public function mergeAssociative(StructuredFieldProvider|iterable ...$others): self + { + $members = $this->members; + foreach ($others as $other) { + if ($other instanceof StructuredFieldProvider) { + $other = $other->toStructuredField(); + if (!$other instanceof Dictionary && !$other instanceof Parameters) { + throw new InvalidArgument('The "'.$other::class.'" instance can not be used for creating a .'.self::class.' structured field.'); + } + } + + if ($other instanceof self || $other instanceof Dictionary) { + $other = $other->toAssociative(); + } + + foreach ($other as $key => $value) { + $members[$key] = $value; + } + } + + return new self($members); + } + + /** + * @param StructuredFieldProvider|Parameters|Dictionary|iterable<array{0:string, 1:SfItemInput}> ...$others + */ + public function mergePairs(Dictionary|Parameters|StructuredFieldProvider|iterable ...$others): self + { + $members = $this->members; + foreach ($others as $other) { + if (!$other instanceof self) { + $other = self::fromPairs($other); + } + foreach ($other->toAssociative() as $key => $value) { + $members[$key] = $value; + } + } + + return new self($members); + } + + /** + * @param string $offset + */ + public function offsetExists(mixed $offset): bool + { + return $this->hasKeys($offset); + } + + /** + * @param string $offset + */ + public function offsetGet(mixed $offset): Item + { + return $this->getByKey($offset); + } + + public function offsetUnset(mixed $offset): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + public function offsetSet(mixed $offset, mixed $value): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + /** + * @param callable(array{0:string, 1:Item}, int): TMap $callback + * + * @template TMap + * + * @return Iterator<TMap> + */ + public function map(callable $callback): Iterator + { + foreach ($this as $offset => $pair) { + yield ($callback)($pair, $offset); + } + } + + /** + * @param callable(TInitial|null, array{0:string, 1:Item}, int): TInitial $callback + * @param TInitial|null $initial + * + * @template TInitial + * + * @return TInitial|null + */ + public function reduce(callable $callback, mixed $initial = null): mixed + { + foreach ($this as $offset => $pair) { + $initial = $callback($initial, $pair, $offset); + } + + return $initial; + } + + /** + * @param callable(array{0:string, 1:Item}, int): bool $callback + */ + public function filter(callable $callback): self + { + return self::fromPairs(new CallbackFilterIterator($this->getIterator(), $callback)); + } + + /** + * @param callable(array{0:string, 1:Item}, array{0:string, 1:Item}): int $callback + */ + public function sort(callable $callback): self + { + $members = iterator_to_array($this); + uasort($members, $callback); + + return self::fromPairs($members); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Parser.php b/vendor/bakame/http-structured-fields/src/Parser.php new file mode 100644 index 000000000..4c7448c15 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Parser.php @@ -0,0 +1,523 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use DateTimeImmutable; +use Exception; +use Stringable; + +use function in_array; +use function ltrim; +use function preg_match; +use function str_contains; +use function strlen; +use function substr; +use function trim; + +/** + * A class to parse HTTP Structured Fields from their HTTP textual representation according to RFC8941. + * + * Based on gapple\StructuredFields\Parser class in Structured Field Values for PHP v1.0.0. + * + * @link https://github.com/gapple/structured-fields/blob/v1.0.0/src/Parser.php + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2 + * + * @see Dictionary::fromHttpValue() + * @see Parameters::fromHttpValue() + * @see OuterList::fromHttpValue() + * @see InnerList::fromHttpValue() + * @see Item::fromHttpValue() + * + * @internal Do not use directly this class as it's behaviour and return type + * MAY change significantly even during a major release cycle. + * + * @phpstan-type SfValue Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool + * @phpstan-type SfParameter array<array{0:string, 1:SfValue}> + * @phpstan-type SfItem array{0:SfValue, 1: SfParameter} + * @phpstan-type SfInnerList array{0:array<SfItem>, 1: SfParameter} + */ +final class Parser +{ + private const REGEXP_BYTES = '/^(?<sequence>:(?<byte>[a-z\d+\/=]*):)/i'; + private const REGEXP_BOOLEAN = '/^\?[01]/'; + private const REGEXP_DATE = '/^@(?<date>-?\d{1,15})(?:[^\d.]|$)/'; + private const REGEXP_DECIMAL = '/^-?\d{1,12}\.\d{1,3}$/'; + private const REGEXP_INTEGER = '/^-?\d{1,15}$/'; + private const REGEXP_TOKEN = "/^(?<token>[a-z*][a-z\d:\/!#\$%&'*+\-.^_`|~]*)/i"; + private const REGEXP_INVALID_CHARACTERS = "/[\r\t\n]|[^\x20-\x7E]/"; + private const REGEXP_VALID_NUMBER = '/^(?<number>-?\d+(?:\.\d+)?)(?:[^\d.]|$)/'; + private const REGEXP_VALID_SPACE = '/^(?<space>,[ \t]*)/'; + private const FIRST_CHARACTER_RANGE_NUMBER = '-1234567890'; + private const FIRST_CHARACTER_RANGE_TOKEN = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*'; + + public function __construct(private readonly Ietf $rfc) + { + } + + /** + * Returns an Item as a PHP list array from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#name-parsing-an-item + * + * + * @throws Exception|SyntaxError + * + * @return SfItem + */ + public function parseItem(Stringable|string $httpValue): array + { + $remainder = trim((string) $httpValue, ' '); + if ('' === $remainder || 1 === preg_match(self::REGEXP_INVALID_CHARACTERS, $remainder)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for an item contains invalid characters."); + } + + [$value, $offset] = $this->extractValue($remainder); + $remainder = substr($remainder, $offset); + if ('' !== $remainder && !str_contains($remainder, ';')) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for an item contains invalid characters."); + } + + return [$value, $this->parseParameters($remainder)]; /* @phpstan-ignore-line */ + } + + /** + * Returns a Parameters ordered map container as a PHP list array from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.2 + * + * @throws SyntaxError|Exception + * + * @return array<SfParameter> + */ + public function parseParameters(Stringable|string $httpValue): array + { + $remainder = trim((string) $httpValue); + [$parameters, $offset] = $this->extractParametersValues($remainder); + if (strlen($remainder) !== $offset) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for Parameters contains invalid characters."); + } + + return $parameters; /* @phpstan-ignore-line */ + } + + /** + * Returns an ordered list represented as a PHP list array from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.1 + * + * @throws SyntaxError|Exception + * + * @return array<SfInnerList|SfItem> + */ + public function parseList(Stringable|string $httpValue): array + { + $list = []; + $remainder = ltrim((string) $httpValue, ' '); + while ('' !== $remainder) { + [$list[], $offset] = $this->extractItemOrInnerList($remainder); + $remainder = self::removeCommaSeparatedWhiteSpaces($remainder, $offset); + } + + return $list; + } + + /** + * Returns a Dictionary represented as a PHP list array from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.2 + * + * @throws SyntaxError|Exception + * + * @return array<array{0:string, 1:SfInnerList|SfItem}> + */ + public function parseDictionary(Stringable|string $httpValue): array + { + $map = []; + $remainder = ltrim((string) $httpValue, ' '); + while ('' !== $remainder) { + $key = Key::fromStringBeginning($remainder)->value; + $remainder = substr($remainder, strlen($key)); + if ('' === $remainder || '=' !== $remainder[0]) { + $remainder = '=?1'.$remainder; + } + $member = [$key]; + + [$member[1], $offset] = $this->extractItemOrInnerList(substr($remainder, 1)); + $remainder = self::removeCommaSeparatedWhiteSpaces($remainder, ++$offset); + $map[] = $member; + } + + return $map; + } + + /** + * Returns an inner list represented as a PHP list array from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.1.2 + * + * @throws SyntaxError|Exception + * + * @return SfInnerList + */ + public function parseInnerList(Stringable|string $httpValue): array + { + $remainder = ltrim((string) $httpValue, ' '); + if ('(' !== $remainder[0]) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a inner list is missing a parenthesis."); + } + + [$list, $offset] = $this->extractInnerList($remainder); + $remainder = self::removeOptionalWhiteSpaces(substr($remainder, $offset)); + if ('' !== $remainder) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a inner list contains invalid data."); + } + + return $list; + } + + /** + * Filter optional white spaces before and after comma. + * + * @see https://tools.ietf.org/html/rfc7230#section-3.2.3 + */ + private static function removeCommaSeparatedWhiteSpaces(string $remainder, int $offset): string + { + $remainder = self::removeOptionalWhiteSpaces(substr($remainder, $offset)); + if ('' === $remainder) { + return ''; + } + + if (1 !== preg_match(self::REGEXP_VALID_SPACE, $remainder, $found)) { + throw new SyntaxError('The HTTP textual representation is missing an excepted comma.'); + } + + $remainder = substr($remainder, strlen($found['space'])); + + if ('' === $remainder) { + throw new SyntaxError('The HTTP textual representation has an unexpected end of line.'); + } + + return $remainder; + } + + /** + * Remove optional white spaces before field value. + * + * @see https://tools.ietf.org/html/rfc7230#section-3.2.3 + */ + private static function removeOptionalWhiteSpaces(string $httpValue): string + { + return ltrim($httpValue, " \t"); + } + + /** + * Returns an item or an inner list as a PHP list array from an HTTP textual representation. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.1.1 + * + * @throws SyntaxError|Exception + * + * @return array{0: SfInnerList|SfItem, 1:int} + */ + private function extractItemOrInnerList(string $httpValue): array + { + if ('(' === $httpValue[0]) { + return $this->extractInnerList($httpValue); + } + + [$item, $remainder] = $this->extractItem($httpValue); + + return [$item, strlen($httpValue) - strlen($remainder)]; + } + + /** + * Returns an inner list represented as a PHP list array from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.1.2 + * + * @throws SyntaxError|Exception + * + * @return array{0: SfInnerList, 1 :int} + */ + private function extractInnerList(string $httpValue): array + { + $list = []; + $remainder = substr($httpValue, 1); + while ('' !== $remainder) { + $remainder = ltrim($remainder, ' '); + + if (')' === $remainder[0]) { + $remainder = substr($remainder, 1); + [$parameters, $offset] = $this->extractParametersValues($remainder); + $remainder = substr($remainder, $offset); + + return [[$list, $parameters], strlen($httpValue) - strlen($remainder)]; + } + + [$list[], $remainder] = $this->extractItem($remainder); + + if ('' !== $remainder && !in_array($remainder[0], [' ', ')'], true)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a inner list is using invalid characters."); + } + } + + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a inner list has an unexpected end of line."); + } + + /** + * Returns an item represented as a PHP array from an HTTP textual representation and the consumed offset in a tuple. + * + * @throws SyntaxError|Exception + * + * @return array{0:SfItem, 1:string} + */ + private function extractItem(string $remainder): array + { + [$value, $offset] = $this->extractValue($remainder); + $remainder = substr($remainder, $offset); + [$parameters, $offset] = $this->extractParametersValues($remainder); + + return [[$value, $parameters], substr($remainder, $offset)]; + } + + /** + * Returns an item value from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.3.1 + * + * @throws SyntaxError|Exception + * + * @return array{0:SfValue, 1:int} + */ + private function extractValue(string $httpValue): array + { + return match (true) { + '"' === $httpValue[0] => self::extractString($httpValue), + ':' === $httpValue[0] => self::extractBytes($httpValue), + '?' === $httpValue[0] => self::extractBoolean($httpValue), + '@' === $httpValue[0] => self::extractDate($httpValue, $this->rfc), + str_starts_with($httpValue, '%"') => self::extractDisplayString($httpValue, $this->rfc), + str_contains(self::FIRST_CHARACTER_RANGE_NUMBER, $httpValue[0]) => self::extractNumber($httpValue), + str_contains(self::FIRST_CHARACTER_RANGE_TOKEN, $httpValue[0]) => self::extractToken($httpValue), + default => throw new SyntaxError("The HTTP textual representation \"$httpValue\" for an item value is unknown or unsupported."), + }; + } + + /** + * Returns a parameters container represented as a PHP associative array from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.3.2 + * + * @throws SyntaxError|Exception + * + * @return array{0:SfParameter, 1:int} + */ + private function extractParametersValues(Stringable|string $httpValue): array + { + $map = []; + $httpValue = (string) $httpValue; + $remainder = $httpValue; + while ('' !== $remainder && ';' === $remainder[0]) { + $remainder = ltrim(substr($remainder, 1), ' '); + $key = Key::fromStringBeginning($remainder)->value; + $member = [$key, true]; + $remainder = substr($remainder, strlen($key)); + if ('' !== $remainder && '=' === $remainder[0]) { + $remainder = substr($remainder, 1); + [$member[1], $offset] = $this->extractValue($remainder); + $remainder = substr($remainder, $offset); + } + + $map[] = $member; + } + + return [$map, strlen($httpValue) - strlen($remainder)]; + } + + /** + * Returns a boolean from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.8 + * + * @return array{0:bool, 1:int} + */ + private static function extractBoolean(string $httpValue): array + { + return match (1) { + preg_match(self::REGEXP_BOOLEAN, $httpValue) => ['1' === $httpValue[1], 2], + default => throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a Boolean contains invalid characters."), + }; + } + + /** + * Returns an int or a float from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.4 + * + * @return array{0:int|float, 1:int} + */ + private static function extractNumber(string $httpValue): array + { + if (1 !== preg_match(self::REGEXP_VALID_NUMBER, $httpValue, $found)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a Number contains invalid characters."); + } + + return match (1) { + preg_match(self::REGEXP_DECIMAL, $found['number']) => [(float) $found['number'], strlen($found['number'])], + preg_match(self::REGEXP_INTEGER, $found['number']) => [(int) $found['number'], strlen($found['number'])], + default => throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a Number contains too much digit."), + }; + } + + /** + * Returns DateTimeImmutable instance from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://httpwg.org/http-extensions/draft-ietf-httpbis-sfbis.html#name-dates + * + * @throws SyntaxError + * @throws Exception + * + * @return array{0:DateTimeImmutable, 1:int} + */ + private static function extractDate(string $httpValue, Ietf $rfc): array + { + if (!$rfc->supports(Type::Date)) { + throw MissingFeature::dueToLackOfSupport(Type::Date, $rfc); + } + + if (1 !== preg_match(self::REGEXP_DATE, $httpValue, $found)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a Date contains invalid characters."); + } + + return [new DateTimeImmutable('@'.$found['date']), strlen($found['date']) + 1]; + } + + /** + * Returns a string from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.5 + * + * @return array{0:string, 1:int} + */ + private static function extractString(string $httpValue): array + { + $offset = 1; + $remainder = substr($httpValue, $offset); + $output = ''; + + if (1 === preg_match(self::REGEXP_INVALID_CHARACTERS, $remainder)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a String contains an invalid end string."); + } + + while ('' !== $remainder) { + $char = $remainder[0]; + $offset += 1; + + if ('"' === $char) { + return [$output, $offset]; + } + + $remainder = substr($remainder, 1); + + if ('\\' !== $char) { + $output .= $char; + continue; + } + + $char = $remainder[0] ?? ''; + $offset += 1; + $remainder = substr($remainder, 1); + + if (!in_array($char, ['"', '\\'], true)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a String contains an invalid end string."); + } + + $output .= $char; + } + + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a String contains an invalid end string."); + } + + /** + * Returns a string from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-sfbis#section-4.2.10 + * + * @return array{0:DisplayString, 1:int} + */ + private static function extractDisplayString(string $httpValue, Ietf $rfc): array + { + if (!$rfc->supports(Type::DisplayString)) { + throw MissingFeature::dueToLackOfSupport(Type::DisplayString, $rfc); + } + + $offset = 2; + $remainder = substr($httpValue, $offset); + $output = ''; + + if (1 === preg_match(self::REGEXP_INVALID_CHARACTERS, $remainder)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a DisplayString contains an invalid character string."); + } + + while ('' !== $remainder) { + $char = $remainder[0]; + $offset += 1; + + if ('"' === $char) { + return [DisplayString::fromEncoded($output), $offset]; + } + + $remainder = substr($remainder, 1); + if ('%' !== $char) { + $output .= $char; + continue; + } + + $octet = substr($remainder, 0, 2); + $offset += 2; + if (1 === preg_match('/^[0-9a-f]]{2}$/', $octet)) { + throw new SyntaxError("The HTTP textual representation '$httpValue' for a DisplayString contains uppercased percent encoding sequence."); + } + + $remainder = substr($remainder, 2); + $output .= $char.$octet; + } + + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a DisplayString contains an invalid end string."); + } + + /** + * Returns a Token from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.6 + * + * @return array{0:Token, 1:int} + */ + private static function extractToken(string $httpValue): array + { + preg_match(self::REGEXP_TOKEN, $httpValue, $found); + + $token = $found['token'] ?? throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a Token contains invalid characters."); + + return [Token::fromString($token), strlen($token)]; + } + + /** + * Returns a Byte Sequence from an HTTP textual representation and the consumed offset in a tuple. + * + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-4.2.7 + * + * @return array{0:Bytes, 1:int} + */ + private static function extractBytes(string $httpValue): array + { + if (1 !== preg_match(self::REGEXP_BYTES, $httpValue, $found)) { + throw new SyntaxError("The HTTP textual representation \"$httpValue\" for a Byte Sequence contains invalid characters."); + } + + return [Bytes::fromEncoded($found['byte']), strlen($found['sequence'])]; + } +} diff --git a/vendor/bakame/http-structured-fields/src/StructuredFieldError.php b/vendor/bakame/http-structured-fields/src/StructuredFieldError.php new file mode 100644 index 000000000..fa823f6c8 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/StructuredFieldError.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use Throwable; + +interface StructuredFieldError extends Throwable +{ +} diff --git a/vendor/bakame/http-structured-fields/src/StructuredFieldProvider.php b/vendor/bakame/http-structured-fields/src/StructuredFieldProvider.php new file mode 100644 index 000000000..fd9e2be99 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/StructuredFieldProvider.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use DateTimeImmutable; +use DateTimeInterface; + +/** + * @phpstan-type SfType Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool + * @phpstan-type SfTypeInput SfType|DateTimeInterface + * @phpstan-type SfList InnerList|OuterList + * @phpstan-type SfOrderedMap Dictionary|Parameters + * @phpstan-type SfDataType SfList|SfOrderedMap|Item + * @phpstan-type SfItemInput SfTypeInput|SfDataType|StructuredFieldProvider + * @phpstan-type SfMemberInput iterable<SfItemInput>|SfItemInput + * @phpstan-type SfParameterInput iterable<array{0:string, 1?:SfItemInput}> + * @phpstan-type SfInnerListPair array{0:iterable<SfItemInput>, 1?:Parameters|SfParameterInput} + * @phpstan-type SfItemPair array{0:SfTypeInput, 1?:Parameters|SfParameterInput} + */ +interface StructuredFieldProvider +{ + /** + * Returns one of the StructuredField Data Type class. + */ + public function toStructuredField(): Dictionary|InnerList|Item|OuterList|Parameters; +} diff --git a/vendor/bakame/http-structured-fields/src/SyntaxError.php b/vendor/bakame/http-structured-fields/src/SyntaxError.php new file mode 100644 index 000000000..304671fe9 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/SyntaxError.php @@ -0,0 +1,11 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use InvalidArgumentException; + +class SyntaxError extends InvalidArgumentException implements StructuredFieldError +{ +} diff --git a/vendor/bakame/http-structured-fields/src/Token.php b/vendor/bakame/http-structured-fields/src/Token.php new file mode 100644 index 000000000..88f41dbe8 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Token.php @@ -0,0 +1,52 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use Stringable; +use Throwable; + +use function preg_match; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#name-tokens + */ +final class Token +{ + private function __construct(private readonly string $value) + { + if (1 !== preg_match("/^([a-z*][a-z\d:\/!#\$%&'*+\-.^_`|~]*)$/i", $this->value)) { + throw new SyntaxError('The token '.$this->value.' contains invalid characters.'); + } + } + + public function toString(): string + { + return $this->value; + } + + public static function tryFromString(Stringable|string $value): ?self + { + try { + return self::fromString($value); + } catch (Throwable) { + return null; + } + } + + public static function fromString(Stringable|string $value): self + { + return new self((string)$value); + } + + public function equals(mixed $other): bool + { + return $other instanceof self && $other->value === $this->value; + } + + public function type(): Type + { + return Type::Token; + } +} diff --git a/vendor/bakame/http-structured-fields/src/Type.php b/vendor/bakame/http-structured-fields/src/Type.php new file mode 100644 index 000000000..44eb8764d --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Type.php @@ -0,0 +1,88 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields; + +use DateTimeInterface; + +use function abs; +use function floor; +use function gettype; +use function is_float; +use function is_int; +use function is_object; +use function is_string; +use function preg_match; + +/** + * @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.3 + */ +enum Type: string +{ + private const MAXIMUM_INT = 999_999_999_999_999; + private const MAXIMUM_FLOAT = 999_999_999_999; + + case Integer = 'integer'; + case Decimal = 'decimal'; + case String = 'string'; + case Token = 'token'; + case Bytes = 'binary'; + case DisplayString = 'displaystring'; + case Boolean = 'boolean'; + case Date = 'date'; + + public function equals(mixed $other): bool + { + return match (true) { + $other instanceof Item => $other->type() === $this, + default => $other instanceof self && $other === $this, + }; + } + + public function isOneOf(mixed ...$other): bool + { + foreach ($other as $item) { + if ($this->equals($item)) { + return true; + } + } + + return false; + } + + /** + * @throws SyntaxError if the value can not be resolved into a supported HTTP structured field data type + */ + public static function fromVariable(Item|Token|DisplayString|Bytes|DateTimeInterface|int|float|bool|string $value): self + { + return self::tryFromVariable($value) ?? throw new SyntaxError(match (true) { + $value instanceof DateTimeInterface => 'The integer representation of a date is limited to 15 digits for a HTTP structured field date type.', + is_int($value) => 'The integer is limited to 15 digits for a HTTP structured field integer type.', + is_float($value) => 'The integer portion of decimals is limited to 12 digits for a HTTP structured field decimal type.', + is_string($value) => 'The string contains characters that are invalid for a HTTP structured field string type', + default => (is_object($value) ? 'An instance of "'.$value::class.'"' : 'A value of type "'.gettype($value).'"').' can not be used as an HTTP structured field value type.', + }); + } + + public static function tryFromVariable(mixed $variable): ?self + { + return match (true) { + $variable instanceof Item, + $variable instanceof Token, + $variable instanceof DisplayString, + $variable instanceof Bytes => $variable->type(), + $variable instanceof DateTimeInterface && self::MAXIMUM_INT >= abs($variable->getTimestamp()) => Type::Date, + is_int($variable) && self::MAXIMUM_INT >= abs($variable) => Type::Integer, + is_float($variable) && self::MAXIMUM_FLOAT >= abs(floor($variable)) => Type::Decimal, + is_bool($variable) => Type::Boolean, + is_string($variable) && 1 !== preg_match('/[^\x20-\x7f]/', $variable) => Type::String, + default => null, + }; + } + + public function supports(mixed $value): bool + { + return self::tryFromVariable($value)?->equals($this) ?? false; + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/ErrorCode.php b/vendor/bakame/http-structured-fields/src/Validation/ErrorCode.php new file mode 100644 index 000000000..3f6ed43ae --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/ErrorCode.php @@ -0,0 +1,26 @@ +<?php + +namespace Bakame\Http\StructuredFields\Validation; + +/** + * General Error Code-. + * + * When adding new codes the name MUST be prefixed with + * a `@` to avoid conflicting with parameters keys. + */ +enum ErrorCode: string +{ + case ItemFailedParsing = '@item.failed.parsing'; + case ItemValueFailedValidation = '@item.value.failed.validation'; + case ParametersFailedParsing = '@parameters.failed.parsing'; + case ParametersMissingConstraints = '@parameters.missing.constraints'; + case ParametersFailedCriteria = '@parameters.failed.criteria'; + + /** + * @return array<string> + */ + public static function list(): array + { + return array_map(fn (self $case) => $case->value, self::cases()); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/ItemValidator.php b/vendor/bakame/http-structured-fields/src/Validation/ItemValidator.php new file mode 100644 index 000000000..21d8cdd2f --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/ItemValidator.php @@ -0,0 +1,103 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +use Bakame\Http\StructuredFields\Item; +use Bakame\Http\StructuredFields\StructuredFieldProvider; +use Bakame\Http\StructuredFields\SyntaxError; +use Stringable; + +/** + * Structured field Item validator. + * + * @phpstan-import-type SfType from StructuredFieldProvider + */ +final class ItemValidator +{ + /** @var callable(SfType): (string|bool) */ + private mixed $valueConstraint; + private ParametersValidator $parametersConstraint; + + /** + * @param callable(SfType): (string|bool) $valueConstraint + */ + private function __construct( + callable $valueConstraint, + ParametersValidator $parametersConstraint, + ) { + $this->valueConstraint = $valueConstraint; + $this->parametersConstraint = $parametersConstraint; + } + + public static function new(): self + { + return new self(fn (mixed $value) => false, ParametersValidator::new()); + } + + /** + * Validates the Item value. + * + * On success populate the result item property + * On failure populates the result errors property + * + * @param callable(SfType): (string|bool) $constraint + */ + public function value(callable $constraint): self + { + return new self($constraint, $this->parametersConstraint); + } + + /** + * Validates the Item parameters as a whole. + * + * On failure populates the result errors property + */ + public function parameters(ParametersValidator $constraint): self + { + return new self($this->valueConstraint, $constraint); + } + + public function __invoke(Item|Stringable|string $item): bool|string + { + $result = $this->validate($item); + + return $result->isSuccess() ? true : (string) $result->errors; + } + + /** + * Validates the structured field Item. + */ + public function validate(Item|Stringable|string $item): Result + { + $violations = new ViolationList(); + if (!$item instanceof Item) { + try { + $item = Item::fromHttpValue($item); + } catch (SyntaxError $exception) { + $violations->add(ErrorCode::ItemFailedParsing->value, new Violation('The item string could not be parsed.', previous: $exception)); + + return Result::failed($violations); + } + } + + try { + $itemValue = $item->value($this->valueConstraint); + } catch (Violation $exception) { + $itemValue = null; + $violations->add(ErrorCode::ItemValueFailedValidation->value, $exception); + } + + $validate = $this->parametersConstraint->validate($item->parameters()); + $violations->addAll($validate->errors); + if ($violations->isNotEmpty()) { + return Result::failed($violations); + } + + /** @var ValidatedParameters $validatedParameters */ + $validatedParameters = $validate->data; + + return Result::success(new ValidatedItem($itemValue, $validatedParameters)); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/ParametersValidator.php b/vendor/bakame/http-structured-fields/src/Validation/ParametersValidator.php new file mode 100644 index 000000000..e851b9686 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/ParametersValidator.php @@ -0,0 +1,244 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +use Bakame\Http\StructuredFields\Parameters; +use Bakame\Http\StructuredFields\StructuredFieldProvider; +use Bakame\Http\StructuredFields\SyntaxError; +use Stringable; + +/** + * Structured field Item validator. + * + * @phpstan-import-type SfType from StructuredFieldProvider + * + * @phpstan-type SfParameterKeyRule array{validate?:callable(SfType): (bool|string), required?:bool|string, default?:SfType|null} + * @phpstan-type SfParameterIndexRule array{validate?:callable(SfType, string): (bool|string), required?:bool|string, default?:array{0:string, 1:SfType}|array{}} + */ +final class ParametersValidator +{ + public const USE_KEYS = 1; + public const USE_INDICES = 2; + + /** @var ?callable(Parameters): (string|bool) */ + private mixed $criteria; + private int $type; + /** @var array<string, SfParameterKeyRule>|array<int, SfParameterIndexRule> */ + private array $filterConstraints; + + /** + * @param ?callable(Parameters): (string|bool) $criteria + * @param array<string, SfParameterKeyRule>|array<int, SfParameterIndexRule> $filterConstraints + */ + private function __construct( + ?callable $criteria = null, + int $type = self::USE_KEYS, + array $filterConstraints = [], + ) { + $this->criteria = $criteria; + $this->type = $type; + $this->filterConstraints = $filterConstraints; + } + + public static function new(): self + { + return new self(); + } + + /** + * Validates the Item parameters as a whole. + * + * On failure populates the result errors property + * + * @param ?callable(Parameters): (string|bool) $criteria + */ + public function filterByCriteria(?callable $criteria, int $type = self::USE_KEYS): self + { + return new self($criteria, [] === $this->filterConstraints ? $type : $this->type, $this->filterConstraints); + } + + /** + * Validate each parameters value per name. + * + * On success populate the result item property + * On failure populates the result errors property + * + * @param array<string, SfParameterKeyRule> $constraints + */ + public function filterByKeys(array $constraints): self + { + return new self($this->criteria, self::USE_KEYS, $constraints); + } + + /** + * Validate each parameters value per indices. + * + * On success populate the result item property + * On failure populates the result errors property + * + * @param array<int, SfParameterIndexRule> $constraints + */ + public function filterByIndices(array $constraints): self + { + return new self($this->criteria, self::USE_INDICES, $constraints); + } + + public function __invoke(Parameters|Stringable|string $parameters): bool|string + { + $result = $this->validate($parameters); + + return $result->isSuccess() ? true : (string) $result->errors; + } + + /** + * Validates the structured field Item. + */ + public function validate(Parameters|Stringable|string $parameters): Result + { + $violations = new ViolationList(); + if (!$parameters instanceof Parameters) { + try { + $parameters = Parameters::fromHttpValue($parameters); + } catch (SyntaxError $exception) { + $violations->add(ErrorCode::ParametersFailedParsing->value, new Violation('The parameters string could not be parsed.', previous: $exception)); + + return Result::failed($violations); + } + } + + if ([] === $this->filterConstraints && null === $this->criteria) { + $violations->add(ErrorCode::ParametersMissingConstraints->value, new Violation('The parameters constraints are missing.')); + } + + $parsedParameters = new ValidatedParameters(); + if ([] !== $this->filterConstraints) { + $parsedParameters = match ($this->type) { + self::USE_INDICES => $this->validateByIndices($parameters), + default => $this->validateByKeys($parameters), + }; + + if ($parsedParameters->isFailed()) { + $violations->addAll($parsedParameters->errors); + } else { + $parsedParameters = $parsedParameters->data; + } + } + + $errorMessage = $this->validateByCriteria($parameters); + if (!is_bool($errorMessage)) { + $violations->add(ErrorCode::ParametersFailedCriteria->value, new Violation($errorMessage)); + } + + /** @var ValidatedParameters $parsedParameters */ + $parsedParameters = $parsedParameters ?? new ValidatedParameters(); + if ([] === $this->filterConstraints && true === $errorMessage) { + $parsedParameters = new ValidatedParameters(match ($this->type) { + self::USE_KEYS => $this->toAssociative($parameters), + default => $this->toList($parameters), + }); + } + + return match ($violations->isNotEmpty()) { + true => Result::failed($violations), + default => Result::success($parsedParameters), + }; + } + + private function validateByCriteria(Parameters $parameters): bool|string + { + if (null === $this->criteria) { + return true; + } + + $errorMessage = ($this->criteria)($parameters); + if (true === $errorMessage) { + return true; + } + + if (!is_string($errorMessage) || '' === trim($errorMessage)) { + $errorMessage = 'The parameters constraints are not met.'; + } + + return $errorMessage; + } + + /** + * Validate the current parameter object using its keys and return the parsed values and the errors. + * + * @return Result<ValidatedParameters>|Result<null> + */ + private function validateByKeys(Parameters $parameters): Result /* @phpstan-ignore-line */ + { + $data = []; + $violations = new ViolationList(); + /** + * @var string $key + * @var SfParameterKeyRule $rule + */ + foreach ($this->filterConstraints as $key => $rule) { + try { + $data[$key] = $parameters->valueByKey($key, $rule['validate'] ?? null, $rule['required'] ?? false, $rule['default'] ?? null); + } catch (Violation $exception) { + $violations[$key] = $exception; + } + } + + return match ($violations->isNotEmpty()) { + true => Result::failed($violations), + default => Result::success(new ValidatedParameters($data)), + }; + } + + /** + * Validate the current parameter object using its indices and return the parsed values and the errors. + */ + public function validateByIndices(Parameters $parameters): Result + { + $data = []; + $violations = new ViolationList(); + /** + * @var int $index + * @var SfParameterIndexRule $rule + */ + foreach ($this->filterConstraints as $index => $rule) { + try { + $data[$index] = $parameters->valueByIndex($index, $rule['validate'] ?? null, $rule['required'] ?? false, $rule['default'] ?? []); + } catch (Violation $exception) { + $violations[$index] = $exception; + } + } + + return match ($violations->isNotEmpty()) { + true => Result::failed($violations), + default => Result::success(new ValidatedParameters($data)), + }; + } + + /** + * @return array<string,SfType> + */ + private function toAssociative(Parameters $parameters): array + { + $assoc = []; + foreach ($parameters as $parameter) { + $assoc[$parameter[0]] = $parameter[1]->value(); + } + + return $assoc; + } + + /** + * @return array<int, array{0:string, 1:SfType}> + */ + private function toList(Parameters $parameters): array + { + $list = []; + foreach ($parameters as $index => $parameter) { + $list[$index] = [$parameter[0], $parameter[1]->value()]; + } + + return $list; + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/Result.php b/vendor/bakame/http-structured-fields/src/Validation/Result.php new file mode 100644 index 000000000..f765efda0 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/Result.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +final class Result +{ + private function __construct( + public readonly ValidatedParameters|ValidatedItem|null $data, + public readonly ViolationList $errors, + ) { + } + + public function isSuccess(): bool + { + return $this->errors->isEmpty(); + } + + public function isFailed(): bool + { + return $this->errors->isNotEmpty(); + } + + public static function success(ValidatedItem|ValidatedParameters $data): self + { + return new self($data, new ViolationList()); + } + + public static function failed(ViolationList $errors): self + { + return new self(null, $errors); + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/ValidatedItem.php b/vendor/bakame/http-structured-fields/src/Validation/ValidatedItem.php new file mode 100644 index 000000000..df61a1aa8 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/ValidatedItem.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +use Bakame\Http\StructuredFields\Bytes; +use Bakame\Http\StructuredFields\DisplayString; +use Bakame\Http\StructuredFields\Token; +use DateTimeImmutable; + +final class ValidatedItem +{ + public function __construct( + public readonly Bytes|Token|DisplayString|DateTimeImmutable|string|int|float|bool|null $value, + public readonly ValidatedParameters $parameters = new ValidatedParameters(), + ) { + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/ValidatedParameters.php b/vendor/bakame/http-structured-fields/src/Validation/ValidatedParameters.php new file mode 100644 index 000000000..c7f5b5eb6 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/ValidatedParameters.php @@ -0,0 +1,68 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +use ArrayAccess; +use Bakame\Http\StructuredFields\ForbiddenOperation; +use Bakame\Http\StructuredFields\InvalidOffset; +use Bakame\Http\StructuredFields\StructuredFieldProvider; +use Countable; +use Iterator; +use IteratorAggregate; + +/** + * @phpstan-import-type SfType from StructuredFieldProvider + * + * @implements ArrayAccess<array-key, array{0:string, 1:SfType}|array{}|SfType|null> + * @implements IteratorAggregate<array-key, array{0:string, 1:SfType}|array{}|SfType|null> + */ +final class ValidatedParameters implements ArrayAccess, Countable, IteratorAggregate +{ + /** + * @param array<array-key, array{0:string, 1:SfType}|array{}|SfType|null> $values + */ + public function __construct( + private readonly array $values = [], + ) { + } + + public function count(): int + { + return count($this->values); + } + + public function getIterator(): Iterator + { + yield from $this->values; + } + + public function offsetExists($offset): bool + { + return array_key_exists($offset, $this->values); + } + + public function offsetGet($offset): mixed + { + return $this->offsetExists($offset) ? $this->values[$offset] : throw InvalidOffset::dueToMemberNotFound($offset); + } + + public function offsetUnset(mixed $offset): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + public function offsetSet(mixed $offset, mixed $value): void + { + throw new ForbiddenOperation(self::class.' instance can not be updated using '.ArrayAccess::class.' methods.'); + } + + /** + * @return array<array-key, array{0:string, 1:SfType}|array{}|SfType|null> + */ + public function all(): array + { + return $this->values; + } +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/Violation.php b/vendor/bakame/http-structured-fields/src/Validation/Violation.php new file mode 100644 index 000000000..ec666de98 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/Violation.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +use Bakame\Http\StructuredFields\StructuredFieldError; +use LogicException; + +final class Violation extends LogicException implements StructuredFieldError +{ +} diff --git a/vendor/bakame/http-structured-fields/src/Validation/ViolationList.php b/vendor/bakame/http-structured-fields/src/Validation/ViolationList.php new file mode 100644 index 000000000..8cbf5e741 --- /dev/null +++ b/vendor/bakame/http-structured-fields/src/Validation/ViolationList.php @@ -0,0 +1,169 @@ +<?php + +declare(strict_types=1); + +namespace Bakame\Http\StructuredFields\Validation; + +use ArrayAccess; +use Bakame\Http\StructuredFields\InvalidOffset; +use Countable; +use Iterator; +use IteratorAggregate; +use Stringable; +use TypeError; + +use function array_filter; +use function array_map; +use function count; +use function implode; +use function is_int; + +use const ARRAY_FILTER_USE_BOTH; + +/** + * @implements IteratorAggregate<array-key,Violation> + * @implements ArrayAccess<array-key,Violation> + */ +final class ViolationList implements IteratorAggregate, Countable, ArrayAccess, Stringable +{ + /** @var array<Violation> */ + private array $errors = []; + + /** + * @param iterable<array-key, Violation> $errors + */ + public function __construct(iterable $errors = []) + { + $this->addAll($errors); + } + + public function count(): int + { + return count($this->errors); + } + + public function getIterator(): Iterator + { + yield from $this->errors; + } + + public function __toString(): string + { + return implode(PHP_EOL, array_map(fn (Violation $e): string => $e->getMessage(), $this->errors)); + } + + /** + * @return array<array-key, string> + */ + public function summary(): array + { + return array_map(fn (Violation $e): string => $e->getMessage(), $this->errors); + } + + public function isEmpty(): bool + { + return [] === $this->errors; + } + + public function isNotEmpty(): bool + { + return ! $this->isEmpty(); + } + + /** + * @param string|int $offset + */ + public function offsetExists(mixed $offset): bool + { + return $this->has($offset); + } + + /** + * @param string|int $offset + * + * @return Violation + */ + public function offsetGet(mixed $offset): mixed + { + return $this->get($offset); + } + + /** + * @param string|int $offset + */ + public function offsetUnset(mixed $offset): void + { + unset($this->errors[$offset]); + } + + /** + * @param string|int|null $offset + * @param Violation $value + */ + public function offsetSet(mixed $offset, mixed $value): void + { + if (null === $offset) { + throw new TypeError('null can not be used as a valid offset value.'); + } + $this->add($offset, $value); + } + + public function has(string|int $offset): bool + { + if (is_int($offset)) { + return null !== $this->filterIndex($offset); + } + + return array_key_exists($offset, $this->errors); + } + + public function get(string|int $offset): Violation + { + return $this->errors[$this->filterIndex($offset) ?? throw InvalidOffset::dueToIndexNotFound($offset)]; + } + + public function add(string|int $offset, Violation $error): void + { + $this->errors[$offset] = $error; + } + + /** + * @param iterable<array-key, Violation> $errors + */ + public function addAll(iterable $errors): void + { + foreach ($errors as $offset => $error) { + $this->add($offset, $error); + } + } + + private function filterIndex(string|int $index, int|null $max = null): string|int|null + { + if (!is_int($index)) { + return $index; + } + + $max ??= count($this->errors); + + return match (true) { + [] === $this->errors, + 0 > $max + $index, + 0 > $max - $index - 1 => null, + 0 > $index => $max + $index, + default => $index, + }; + } + + /** + * @param callable(Violation, array-key): bool $callback + */ + public function filter(callable $callback): self + { + return new self(array_filter($this->errors, $callback, ARRAY_FILTER_USE_BOTH)); + } + + public function toException(): Violation + { + return new Violation((string) $this); + } +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 3b4744860..b5fc26567 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,6 +6,36 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'Bakame\\Http\\StructuredFields\\Bytes' => $vendorDir . '/bakame/http-structured-fields/src/Bytes.php', + 'Bakame\\Http\\StructuredFields\\DataType' => $vendorDir . '/bakame/http-structured-fields/src/DataType.php', + 'Bakame\\Http\\StructuredFields\\Dictionary' => $vendorDir . '/bakame/http-structured-fields/src/Dictionary.php', + 'Bakame\\Http\\StructuredFields\\DisplayString' => $vendorDir . '/bakame/http-structured-fields/src/DisplayString.php', + 'Bakame\\Http\\StructuredFields\\ForbiddenOperation' => $vendorDir . '/bakame/http-structured-fields/src/ForbiddenOperation.php', + 'Bakame\\Http\\StructuredFields\\Ietf' => $vendorDir . '/bakame/http-structured-fields/src/Ietf.php', + 'Bakame\\Http\\StructuredFields\\InnerList' => $vendorDir . '/bakame/http-structured-fields/src/InnerList.php', + 'Bakame\\Http\\StructuredFields\\InvalidArgument' => $vendorDir . '/bakame/http-structured-fields/src/InvalidArgument.php', + 'Bakame\\Http\\StructuredFields\\InvalidOffset' => $vendorDir . '/bakame/http-structured-fields/src/InvalidOffset.php', + 'Bakame\\Http\\StructuredFields\\Item' => $vendorDir . '/bakame/http-structured-fields/src/Item.php', + 'Bakame\\Http\\StructuredFields\\Key' => $vendorDir . '/bakame/http-structured-fields/src/Key.php', + 'Bakame\\Http\\StructuredFields\\Member' => $vendorDir . '/bakame/http-structured-fields/src/Member.php', + 'Bakame\\Http\\StructuredFields\\MissingFeature' => $vendorDir . '/bakame/http-structured-fields/src/MissingFeature.php', + 'Bakame\\Http\\StructuredFields\\OuterList' => $vendorDir . '/bakame/http-structured-fields/src/OuterList.php', + 'Bakame\\Http\\StructuredFields\\ParameterAccess' => $vendorDir . '/bakame/http-structured-fields/src/ParameterAccess.php', + 'Bakame\\Http\\StructuredFields\\Parameters' => $vendorDir . '/bakame/http-structured-fields/src/Parameters.php', + 'Bakame\\Http\\StructuredFields\\Parser' => $vendorDir . '/bakame/http-structured-fields/src/Parser.php', + 'Bakame\\Http\\StructuredFields\\StructuredFieldError' => $vendorDir . '/bakame/http-structured-fields/src/StructuredFieldError.php', + 'Bakame\\Http\\StructuredFields\\StructuredFieldProvider' => $vendorDir . '/bakame/http-structured-fields/src/StructuredFieldProvider.php', + 'Bakame\\Http\\StructuredFields\\SyntaxError' => $vendorDir . '/bakame/http-structured-fields/src/SyntaxError.php', + 'Bakame\\Http\\StructuredFields\\Token' => $vendorDir . '/bakame/http-structured-fields/src/Token.php', + 'Bakame\\Http\\StructuredFields\\Type' => $vendorDir . '/bakame/http-structured-fields/src/Type.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ErrorCode' => $vendorDir . '/bakame/http-structured-fields/src/Validation/ErrorCode.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ItemValidator' => $vendorDir . '/bakame/http-structured-fields/src/Validation/ItemValidator.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ParametersValidator' => $vendorDir . '/bakame/http-structured-fields/src/Validation/ParametersValidator.php', + 'Bakame\\Http\\StructuredFields\\Validation\\Result' => $vendorDir . '/bakame/http-structured-fields/src/Validation/Result.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ValidatedItem' => $vendorDir . '/bakame/http-structured-fields/src/Validation/ValidatedItem.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ValidatedParameters' => $vendorDir . '/bakame/http-structured-fields/src/Validation/ValidatedParameters.php', + 'Bakame\\Http\\StructuredFields\\Validation\\Violation' => $vendorDir . '/bakame/http-structured-fields/src/Validation/Violation.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ViolationList' => $vendorDir . '/bakame/http-structured-fields/src/Validation/ViolationList.php', 'Brick\\Math\\BigDecimal' => $vendorDir . '/brick/math/src/BigDecimal.php', 'Brick\\Math\\BigInteger' => $vendorDir . '/brick/math/src/BigInteger.php', 'Brick\\Math\\BigNumber' => $vendorDir . '/brick/math/src/BigNumber.php', @@ -44,6 +74,37 @@ return array( 'CommerceGuys\\Intl\\NumberFormat\\NumberFormatRepository' => $vendorDir . '/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php', 'CommerceGuys\\Intl\\NumberFormat\\NumberFormatRepositoryInterface' => $vendorDir . '/commerceguys/intl/src/NumberFormat/NumberFormatRepositoryInterface.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'GuzzleHttp\\Psr7\\AppendStream' => $vendorDir . '/guzzlehttp/psr7/src/AppendStream.php', + 'GuzzleHttp\\Psr7\\BufferStream' => $vendorDir . '/guzzlehttp/psr7/src/BufferStream.php', + 'GuzzleHttp\\Psr7\\CachingStream' => $vendorDir . '/guzzlehttp/psr7/src/CachingStream.php', + 'GuzzleHttp\\Psr7\\DroppingStream' => $vendorDir . '/guzzlehttp/psr7/src/DroppingStream.php', + 'GuzzleHttp\\Psr7\\Exception\\MalformedUriException' => $vendorDir . '/guzzlehttp/psr7/src/Exception/MalformedUriException.php', + 'GuzzleHttp\\Psr7\\FnStream' => $vendorDir . '/guzzlehttp/psr7/src/FnStream.php', + 'GuzzleHttp\\Psr7\\Header' => $vendorDir . '/guzzlehttp/psr7/src/Header.php', + 'GuzzleHttp\\Psr7\\HttpFactory' => $vendorDir . '/guzzlehttp/psr7/src/HttpFactory.php', + 'GuzzleHttp\\Psr7\\InflateStream' => $vendorDir . '/guzzlehttp/psr7/src/InflateStream.php', + 'GuzzleHttp\\Psr7\\LazyOpenStream' => $vendorDir . '/guzzlehttp/psr7/src/LazyOpenStream.php', + 'GuzzleHttp\\Psr7\\LimitStream' => $vendorDir . '/guzzlehttp/psr7/src/LimitStream.php', + 'GuzzleHttp\\Psr7\\Message' => $vendorDir . '/guzzlehttp/psr7/src/Message.php', + 'GuzzleHttp\\Psr7\\MessageTrait' => $vendorDir . '/guzzlehttp/psr7/src/MessageTrait.php', + 'GuzzleHttp\\Psr7\\MimeType' => $vendorDir . '/guzzlehttp/psr7/src/MimeType.php', + 'GuzzleHttp\\Psr7\\MultipartStream' => $vendorDir . '/guzzlehttp/psr7/src/MultipartStream.php', + 'GuzzleHttp\\Psr7\\NoSeekStream' => $vendorDir . '/guzzlehttp/psr7/src/NoSeekStream.php', + 'GuzzleHttp\\Psr7\\PumpStream' => $vendorDir . '/guzzlehttp/psr7/src/PumpStream.php', + 'GuzzleHttp\\Psr7\\Query' => $vendorDir . '/guzzlehttp/psr7/src/Query.php', + 'GuzzleHttp\\Psr7\\Request' => $vendorDir . '/guzzlehttp/psr7/src/Request.php', + 'GuzzleHttp\\Psr7\\Response' => $vendorDir . '/guzzlehttp/psr7/src/Response.php', + 'GuzzleHttp\\Psr7\\Rfc7230' => $vendorDir . '/guzzlehttp/psr7/src/Rfc7230.php', + 'GuzzleHttp\\Psr7\\ServerRequest' => $vendorDir . '/guzzlehttp/psr7/src/ServerRequest.php', + 'GuzzleHttp\\Psr7\\Stream' => $vendorDir . '/guzzlehttp/psr7/src/Stream.php', + 'GuzzleHttp\\Psr7\\StreamDecoratorTrait' => $vendorDir . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php', + 'GuzzleHttp\\Psr7\\StreamWrapper' => $vendorDir . '/guzzlehttp/psr7/src/StreamWrapper.php', + 'GuzzleHttp\\Psr7\\UploadedFile' => $vendorDir . '/guzzlehttp/psr7/src/UploadedFile.php', + 'GuzzleHttp\\Psr7\\Uri' => $vendorDir . '/guzzlehttp/psr7/src/Uri.php', + 'GuzzleHttp\\Psr7\\UriComparator' => $vendorDir . '/guzzlehttp/psr7/src/UriComparator.php', + 'GuzzleHttp\\Psr7\\UriNormalizer' => $vendorDir . '/guzzlehttp/psr7/src/UriNormalizer.php', + 'GuzzleHttp\\Psr7\\UriResolver' => $vendorDir . '/guzzlehttp/psr7/src/UriResolver.php', + 'GuzzleHttp\\Psr7\\Utils' => $vendorDir . '/guzzlehttp/psr7/src/Utils.php', 'HTMLPurifier' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.php', 'HTMLPurifier_Arborize' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Arborize.php', 'HTMLPurifier_AttrCollections' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php', @@ -276,6 +337,8 @@ return array( 'HTMLPurifier_VarParser_Flexible' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Flexible.php', 'HTMLPurifier_VarParser_Native' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php', 'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php', + 'HttpSignature\\HttpMessageSigner' => $vendorDir . '/macgirvin/http-message-signer/src/HttpMessageSigner.php', + 'HttpSignature\\StructuredFieldTypes' => $vendorDir . '/macgirvin/http-message-signer/src/StructuredFieldTypes.php', 'ID3Parser\\ID3Parser' => $vendorDir . '/lukasreschke/id3parser/src/ID3Parser.php', 'ID3Parser\\getID3\\Tags\\getid3_id3v1' => $vendorDir . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v1.php', 'ID3Parser\\getID3\\Tags\\getid3_id3v2' => $vendorDir . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v2.php', @@ -1619,6 +1682,7 @@ return array( 'Zotlabs\\Lib\\Img_filesize' => $baseDir . '/Zotlabs/Lib/Img_filesize.php', 'Zotlabs\\Lib\\JSalmon' => $baseDir . '/Zotlabs/Lib/JSalmon.php', 'Zotlabs\\Lib\\JcsEddsa2022' => $baseDir . '/Zotlabs/Lib/JcsEddsa2022.php', + 'Zotlabs\\Lib\\JcsEddsa2022SignException' => $baseDir . '/Zotlabs/Lib/JcsEddsa2022SignException.php', 'Zotlabs\\Lib\\Keyutils' => $baseDir . '/Zotlabs/Lib/Keyutils.php', 'Zotlabs\\Lib\\LDSignatures' => $baseDir . '/Zotlabs/Lib/LDSignatures.php', 'Zotlabs\\Lib\\Libsync' => $baseDir . '/Zotlabs/Lib/Libsync.php', @@ -1682,14 +1746,12 @@ return array( 'Zotlabs\\Module\\Branchtopic' => $baseDir . '/Zotlabs/Module/Branchtopic.php', 'Zotlabs\\Module\\Cal' => $baseDir . '/Zotlabs/Module/Cal.php', 'Zotlabs\\Module\\Cdav' => $baseDir . '/Zotlabs/Module/Cdav.php', - 'Zotlabs\\Module\\Ceditor' => $baseDir . '/Zotlabs/Module/Ceditor.php', 'Zotlabs\\Module\\Changeaddr' => $baseDir . '/Zotlabs/Module/Changeaddr.php', 'Zotlabs\\Module\\Channel' => $baseDir . '/Zotlabs/Module/Channel.php', 'Zotlabs\\Module\\Channel_calendar' => $baseDir . '/Zotlabs/Module/Channel_calendar.php', 'Zotlabs\\Module\\Chanview' => $baseDir . '/Zotlabs/Module/Chanview.php', 'Zotlabs\\Module\\Chat' => $baseDir . '/Zotlabs/Module/Chat.php', 'Zotlabs\\Module\\Chatsvc' => $baseDir . '/Zotlabs/Module/Chatsvc.php', - 'Zotlabs\\Module\\Cleditor' => $baseDir . '/Zotlabs/Module/Cleditor.php', 'Zotlabs\\Module\\Cloud' => $baseDir . '/Zotlabs/Module/Cloud.php', 'Zotlabs\\Module\\Cloud_tiles' => $baseDir . '/Zotlabs/Module/Cloud_tiles.php', 'Zotlabs\\Module\\Common' => $baseDir . '/Zotlabs/Module/Common.php', @@ -1865,7 +1927,6 @@ return array( 'Zotlabs\\Module\\Xchan' => $baseDir . '/Zotlabs/Module/Xchan.php', 'Zotlabs\\Module\\Xpoco' => $baseDir . '/Zotlabs/Module/Xpoco.php', 'Zotlabs\\Module\\Xrd' => $baseDir . '/Zotlabs/Module/Xrd.php', - 'Zotlabs\\Module\\Xref' => $baseDir . '/Zotlabs/Module/Xref.php', 'Zotlabs\\Module\\Z6trans' => $baseDir . '/Zotlabs/Module/Z6trans.php', 'Zotlabs\\Module\\Zot' => $baseDir . '/Zotlabs/Module/Zot.php', 'Zotlabs\\Module\\Zot_probe' => $baseDir . '/Zotlabs/Module/Zot_probe.php', diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 070ea14ba..4fa3c3acf 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -13,6 +13,7 @@ return array( 'a1cce3d26cc15c00fcd0b3354bd72c88' => $vendorDir . '/sabre/event/lib/Promise/functions.php', '3569eecfeed3bcf0bad3c998a494ecb8' => $vendorDir . '/sabre/xml/lib/Deserializer/functions.php', '93aa591bc4ca510c520999e34229ee79' => $vendorDir . '/sabre/xml/lib/Serializer/functions.php', + '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', 'ebdb698ed4152ae445614b69b5e4bb6a' => $vendorDir . '/sabre/http/lib/functions.php', '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 3f54528b2..05e9ab3f5 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -40,6 +40,9 @@ return array( 'LanguageDetection\\' => array($vendorDir . '/patrickschur/language-detection/src/LanguageDetection'), 'ID3Parser\\' => array($vendorDir . '/lukasreschke/id3parser/src'), 'Hubzilla\\' => array($baseDir . '/include'), + 'HttpSignature\\' => array($vendorDir . '/macgirvin/http-message-signer/src'), + 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'CommerceGuys\\Intl\\' => array($vendorDir . '/commerceguys/intl/src'), 'Brick\\Math\\' => array($vendorDir . '/brick/math/src'), + 'Bakame\\Http\\StructuredFields\\' => array($vendorDir . '/bakame/http-structured-fields/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 615cc3636..b0e4fc912 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -14,6 +14,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'a1cce3d26cc15c00fcd0b3354bd72c88' => __DIR__ . '/..' . '/sabre/event/lib/Promise/functions.php', '3569eecfeed3bcf0bad3c998a494ecb8' => __DIR__ . '/..' . '/sabre/xml/lib/Deserializer/functions.php', '93aa591bc4ca510c520999e34229ee79' => __DIR__ . '/..' . '/sabre/xml/lib/Serializer/functions.php', + '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', 'ebdb698ed4152ae445614b69b5e4bb6a' => __DIR__ . '/..' . '/sabre/http/lib/functions.php', '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', @@ -93,6 +94,11 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'H' => array ( 'Hubzilla\\' => 9, + 'HttpSignature\\' => 14, + ), + 'G' => + array ( + 'GuzzleHttp\\Psr7\\' => 16, ), 'C' => array ( @@ -101,6 +107,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'B' => array ( 'Brick\\Math\\' => 11, + 'Bakame\\Http\\StructuredFields\\' => 29, ), ); @@ -244,6 +251,14 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d array ( 0 => __DIR__ . '/../..' . '/include', ), + 'HttpSignature\\' => + array ( + 0 => __DIR__ . '/..' . '/macgirvin/http-message-signer/src', + ), + 'GuzzleHttp\\Psr7\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', + ), 'CommerceGuys\\Intl\\' => array ( 0 => __DIR__ . '/..' . '/commerceguys/intl/src', @@ -252,6 +267,10 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d array ( 0 => __DIR__ . '/..' . '/brick/math/src', ), + 'Bakame\\Http\\StructuredFields\\' => + array ( + 0 => __DIR__ . '/..' . '/bakame/http-structured-fields/src', + ), ); public static $prefixesPsr0 = array ( @@ -293,6 +312,36 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d ); public static $classMap = array ( + 'Bakame\\Http\\StructuredFields\\Bytes' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Bytes.php', + 'Bakame\\Http\\StructuredFields\\DataType' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/DataType.php', + 'Bakame\\Http\\StructuredFields\\Dictionary' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Dictionary.php', + 'Bakame\\Http\\StructuredFields\\DisplayString' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/DisplayString.php', + 'Bakame\\Http\\StructuredFields\\ForbiddenOperation' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/ForbiddenOperation.php', + 'Bakame\\Http\\StructuredFields\\Ietf' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Ietf.php', + 'Bakame\\Http\\StructuredFields\\InnerList' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/InnerList.php', + 'Bakame\\Http\\StructuredFields\\InvalidArgument' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/InvalidArgument.php', + 'Bakame\\Http\\StructuredFields\\InvalidOffset' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/InvalidOffset.php', + 'Bakame\\Http\\StructuredFields\\Item' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Item.php', + 'Bakame\\Http\\StructuredFields\\Key' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Key.php', + 'Bakame\\Http\\StructuredFields\\Member' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Member.php', + 'Bakame\\Http\\StructuredFields\\MissingFeature' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/MissingFeature.php', + 'Bakame\\Http\\StructuredFields\\OuterList' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/OuterList.php', + 'Bakame\\Http\\StructuredFields\\ParameterAccess' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/ParameterAccess.php', + 'Bakame\\Http\\StructuredFields\\Parameters' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Parameters.php', + 'Bakame\\Http\\StructuredFields\\Parser' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Parser.php', + 'Bakame\\Http\\StructuredFields\\StructuredFieldError' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/StructuredFieldError.php', + 'Bakame\\Http\\StructuredFields\\StructuredFieldProvider' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/StructuredFieldProvider.php', + 'Bakame\\Http\\StructuredFields\\SyntaxError' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/SyntaxError.php', + 'Bakame\\Http\\StructuredFields\\Token' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Token.php', + 'Bakame\\Http\\StructuredFields\\Type' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Type.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ErrorCode' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/ErrorCode.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ItemValidator' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/ItemValidator.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ParametersValidator' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/ParametersValidator.php', + 'Bakame\\Http\\StructuredFields\\Validation\\Result' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/Result.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ValidatedItem' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/ValidatedItem.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ValidatedParameters' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/ValidatedParameters.php', + 'Bakame\\Http\\StructuredFields\\Validation\\Violation' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/Violation.php', + 'Bakame\\Http\\StructuredFields\\Validation\\ViolationList' => __DIR__ . '/..' . '/bakame/http-structured-fields/src/Validation/ViolationList.php', 'Brick\\Math\\BigDecimal' => __DIR__ . '/..' . '/brick/math/src/BigDecimal.php', 'Brick\\Math\\BigInteger' => __DIR__ . '/..' . '/brick/math/src/BigInteger.php', 'Brick\\Math\\BigNumber' => __DIR__ . '/..' . '/brick/math/src/BigNumber.php', @@ -331,6 +380,37 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'CommerceGuys\\Intl\\NumberFormat\\NumberFormatRepository' => __DIR__ . '/..' . '/commerceguys/intl/src/NumberFormat/NumberFormatRepository.php', 'CommerceGuys\\Intl\\NumberFormat\\NumberFormatRepositoryInterface' => __DIR__ . '/..' . '/commerceguys/intl/src/NumberFormat/NumberFormatRepositoryInterface.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'GuzzleHttp\\Psr7\\AppendStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/AppendStream.php', + 'GuzzleHttp\\Psr7\\BufferStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/BufferStream.php', + 'GuzzleHttp\\Psr7\\CachingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/CachingStream.php', + 'GuzzleHttp\\Psr7\\DroppingStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/DroppingStream.php', + 'GuzzleHttp\\Psr7\\Exception\\MalformedUriException' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Exception/MalformedUriException.php', + 'GuzzleHttp\\Psr7\\FnStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/FnStream.php', + 'GuzzleHttp\\Psr7\\Header' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Header.php', + 'GuzzleHttp\\Psr7\\HttpFactory' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/HttpFactory.php', + 'GuzzleHttp\\Psr7\\InflateStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/InflateStream.php', + 'GuzzleHttp\\Psr7\\LazyOpenStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LazyOpenStream.php', + 'GuzzleHttp\\Psr7\\LimitStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/LimitStream.php', + 'GuzzleHttp\\Psr7\\Message' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Message.php', + 'GuzzleHttp\\Psr7\\MessageTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MessageTrait.php', + 'GuzzleHttp\\Psr7\\MimeType' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MimeType.php', + 'GuzzleHttp\\Psr7\\MultipartStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/MultipartStream.php', + 'GuzzleHttp\\Psr7\\NoSeekStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/NoSeekStream.php', + 'GuzzleHttp\\Psr7\\PumpStream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/PumpStream.php', + 'GuzzleHttp\\Psr7\\Query' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Query.php', + 'GuzzleHttp\\Psr7\\Request' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Request.php', + 'GuzzleHttp\\Psr7\\Response' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Response.php', + 'GuzzleHttp\\Psr7\\Rfc7230' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Rfc7230.php', + 'GuzzleHttp\\Psr7\\ServerRequest' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/ServerRequest.php', + 'GuzzleHttp\\Psr7\\Stream' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Stream.php', + 'GuzzleHttp\\Psr7\\StreamDecoratorTrait' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamDecoratorTrait.php', + 'GuzzleHttp\\Psr7\\StreamWrapper' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/StreamWrapper.php', + 'GuzzleHttp\\Psr7\\UploadedFile' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UploadedFile.php', + 'GuzzleHttp\\Psr7\\Uri' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Uri.php', + 'GuzzleHttp\\Psr7\\UriComparator' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriComparator.php', + 'GuzzleHttp\\Psr7\\UriNormalizer' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriNormalizer.php', + 'GuzzleHttp\\Psr7\\UriResolver' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/UriResolver.php', + 'GuzzleHttp\\Psr7\\Utils' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/Utils.php', 'HTMLPurifier' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.php', 'HTMLPurifier_Arborize' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/Arborize.php', 'HTMLPurifier_AttrCollections' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php', @@ -563,6 +643,8 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'HTMLPurifier_VarParser_Flexible' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Flexible.php', 'HTMLPurifier_VarParser_Native' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php', 'HTMLPurifier_Zipper' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php', + 'HttpSignature\\HttpMessageSigner' => __DIR__ . '/..' . '/macgirvin/http-message-signer/src/HttpMessageSigner.php', + 'HttpSignature\\StructuredFieldTypes' => __DIR__ . '/..' . '/macgirvin/http-message-signer/src/StructuredFieldTypes.php', 'ID3Parser\\ID3Parser' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/ID3Parser.php', 'ID3Parser\\getID3\\Tags\\getid3_id3v1' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v1.php', 'ID3Parser\\getID3\\Tags\\getid3_id3v2' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v2.php', @@ -1906,6 +1988,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'Zotlabs\\Lib\\Img_filesize' => __DIR__ . '/../..' . '/Zotlabs/Lib/Img_filesize.php', 'Zotlabs\\Lib\\JSalmon' => __DIR__ . '/../..' . '/Zotlabs/Lib/JSalmon.php', 'Zotlabs\\Lib\\JcsEddsa2022' => __DIR__ . '/../..' . '/Zotlabs/Lib/JcsEddsa2022.php', + 'Zotlabs\\Lib\\JcsEddsa2022SignException' => __DIR__ . '/../..' . '/Zotlabs/Lib/JcsEddsa2022SignException.php', 'Zotlabs\\Lib\\Keyutils' => __DIR__ . '/../..' . '/Zotlabs/Lib/Keyutils.php', 'Zotlabs\\Lib\\LDSignatures' => __DIR__ . '/../..' . '/Zotlabs/Lib/LDSignatures.php', 'Zotlabs\\Lib\\Libsync' => __DIR__ . '/../..' . '/Zotlabs/Lib/Libsync.php', @@ -1969,14 +2052,12 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'Zotlabs\\Module\\Branchtopic' => __DIR__ . '/../..' . '/Zotlabs/Module/Branchtopic.php', 'Zotlabs\\Module\\Cal' => __DIR__ . '/../..' . '/Zotlabs/Module/Cal.php', 'Zotlabs\\Module\\Cdav' => __DIR__ . '/../..' . '/Zotlabs/Module/Cdav.php', - 'Zotlabs\\Module\\Ceditor' => __DIR__ . '/../..' . '/Zotlabs/Module/Ceditor.php', 'Zotlabs\\Module\\Changeaddr' => __DIR__ . '/../..' . '/Zotlabs/Module/Changeaddr.php', 'Zotlabs\\Module\\Channel' => __DIR__ . '/../..' . '/Zotlabs/Module/Channel.php', 'Zotlabs\\Module\\Channel_calendar' => __DIR__ . '/../..' . '/Zotlabs/Module/Channel_calendar.php', 'Zotlabs\\Module\\Chanview' => __DIR__ . '/../..' . '/Zotlabs/Module/Chanview.php', 'Zotlabs\\Module\\Chat' => __DIR__ . '/../..' . '/Zotlabs/Module/Chat.php', 'Zotlabs\\Module\\Chatsvc' => __DIR__ . '/../..' . '/Zotlabs/Module/Chatsvc.php', - 'Zotlabs\\Module\\Cleditor' => __DIR__ . '/../..' . '/Zotlabs/Module/Cleditor.php', 'Zotlabs\\Module\\Cloud' => __DIR__ . '/../..' . '/Zotlabs/Module/Cloud.php', 'Zotlabs\\Module\\Cloud_tiles' => __DIR__ . '/../..' . '/Zotlabs/Module/Cloud_tiles.php', 'Zotlabs\\Module\\Common' => __DIR__ . '/../..' . '/Zotlabs/Module/Common.php', @@ -2152,7 +2233,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d 'Zotlabs\\Module\\Xchan' => __DIR__ . '/../..' . '/Zotlabs/Module/Xchan.php', 'Zotlabs\\Module\\Xpoco' => __DIR__ . '/../..' . '/Zotlabs/Module/Xpoco.php', 'Zotlabs\\Module\\Xrd' => __DIR__ . '/../..' . '/Zotlabs/Module/Xrd.php', - 'Zotlabs\\Module\\Xref' => __DIR__ . '/../..' . '/Zotlabs/Module/Xref.php', 'Zotlabs\\Module\\Z6trans' => __DIR__ . '/../..' . '/Zotlabs/Module/Z6trans.php', 'Zotlabs\\Module\\Zot' => __DIR__ . '/../..' . '/Zotlabs/Module/Zot.php', 'Zotlabs\\Module\\Zot_probe' => __DIR__ . '/../..' . '/Zotlabs/Module/Zot_probe.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 17c42b0a7..ce20a711c 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,6 +1,91 @@ { "packages": [ { + "name": "bakame/http-structured-fields", + "version": "2.0.0", + "version_normalized": "2.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/bakame-php/http-structured-fields.git", + "reference": "d0fc193e5b173a4e90f2fa589d5b97b2b653b323" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bakame-php/http-structured-fields/zipball/d0fc193e5b173a4e90f2fa589d5b97b2b653b323", + "reference": "d0fc193e5b173a4e90f2fa589d5b97b2b653b323", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "bakame/aide-base32": "dev-main", + "friendsofphp/php-cs-fixer": "^3.65.0", + "httpwg/structured-field-tests": "*@dev", + "phpbench/phpbench": "^1.3.1", + "phpstan/phpstan": "^2.0.3", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpstan/phpstan-phpunit": "^2.0.1", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^10.5.38 || ^11.5.0", + "symfony/var-dumper": "^6.4.15 || ^v7.2.0" + }, + "time": "2024-12-12T08:25:42+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Bakame\\Http\\StructuredFields\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://github.com/nyamsprod/", + "role": "Developer" + } + ], + "description": "A PHP library that parses, validates and serializes HTTP structured fields according to RFC9561 and RFC8941", + "keywords": [ + "headers", + "http", + "http headers", + "http trailers", + "parser", + "rfc8941", + "rfc9651", + "serializer", + "structured fields", + "structured headers", + "structured trailers", + "structured values", + "trailers", + "validation" + ], + "support": { + "docs": "https://github.com/bakame-php/http-structured-fields", + "issues": "https://github.com/bakame-php/http-structured-fields/issues", + "source": "https://github.com/bakame-php/http-structured-fields" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "install-path": "../bakame/http-structured-fields" + }, + { "name": "blueimp/jquery-file-upload", "version": "v10.32.0", "version_normalized": "10.32.0.0", @@ -522,6 +607,125 @@ "install-path": "../ezyang/htmlpurifier" }, { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "version_normalized": "2.7.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "time": "2025-03-27T12:30:47+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/psr7" + }, + { "name": "jbroadway/urlify", "version": "1.2.5-stable", "version_normalized": "1.2.5.0", @@ -907,6 +1111,50 @@ "install-path": "../lukasreschke/id3parser" }, { + "name": "macgirvin/http-message-signer", + "version": "v0.1.7", + "version_normalized": "0.1.7.0", + "source": { + "type": "git", + "url": "https://github.com/macgirvin/HTTP-Message-Signer.git", + "reference": "44db674fb750b4e4909cf1aeb3a18a4c68d938ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/macgirvin/HTTP-Message-Signer/zipball/44db674fb750b4e4909cf1aeb3a18a4c68d938ca", + "reference": "44db674fb750b4e4909cf1aeb3a18a4c68d938ca", + "shasum": "" + }, + "require": { + "bakame/http-structured-fields": "^2.0", + "ext-openssl": "*", + "guzzlehttp/psr7": "^2.0", + "php": "^8.1", + "psr/http-message": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2025-06-25T03:19:43+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "HttpSignature\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "RFC 9421 HTTP Message Signer and Verifier for PSR-7 requests", + "support": { + "issues": "https://github.com/macgirvin/HTTP-Message-Signer/issues", + "source": "https://github.com/macgirvin/HTTP-Message-Signer/tree/v0.1.7" + }, + "install-path": "../macgirvin/http-message-signer" + }, + { "name": "michelf/php-markdown", "version": "2.0.0", "version_normalized": "2.0.0.0", @@ -1533,6 +1781,53 @@ "install-path": "../psr/log" }, { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "version_normalized": "3.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "time": "2019-03-08T08:55:37+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "install-path": "../ralouphie/getallheaders" + }, + { "name": "ramsey/collection", "version": "2.1.1", "version_normalized": "2.1.1.0", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 6fe3de607..5104cac98 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,15 +1,24 @@ <?php return array( 'root' => array( 'name' => 'zotlabs/hubzilla', - 'pretty_version' => 'dev-10.2RC', - 'version' => 'dev-10.2RC', - 'reference' => '457cb748833f0f4926668a18974b6248dac462a7', + 'pretty_version' => 'dev-10.4RC', + 'version' => 'dev-10.4RC', + 'reference' => '7782183ae356db31dbef2dcf785ddc79c00335c1', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => false, ), 'versions' => array( + 'bakame/http-structured-fields' => array( + 'pretty_version' => '2.0.0', + 'version' => '2.0.0.0', + 'reference' => 'd0fc193e5b173a4e90f2fa589d5b97b2b653b323', + 'type' => 'library', + 'install_path' => __DIR__ . '/../bakame/http-structured-fields', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'blueimp/jquery-file-upload' => array( 'pretty_version' => 'v10.32.0', 'version' => '10.32.0.0', @@ -82,6 +91,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'guzzlehttp/psr7' => array( + 'pretty_version' => '2.7.1', + 'version' => '2.7.1.0', + 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/psr7', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'jbroadway/urlify' => array( 'pretty_version' => '1.2.5-stable', 'version' => '1.2.5.0', @@ -127,6 +145,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'macgirvin/http-message-signer' => array( + 'pretty_version' => 'v0.1.7', + 'version' => '0.1.7.0', + 'reference' => '44db674fb750b4e4909cf1aeb3a18a4c68d938ca', + 'type' => 'library', + 'install_path' => __DIR__ . '/../macgirvin/http-message-signer', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'michelf/php-markdown' => array( 'pretty_version' => '2.0.0', 'version' => '2.0.0.0', @@ -199,6 +226,12 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), 'psr/http-message' => array( 'pretty_version' => '2.0', 'version' => '2.0.0.0', @@ -208,6 +241,12 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'psr/http-message-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), 'psr/log' => array( 'pretty_version' => '3.0.2', 'version' => '3.0.2.0', @@ -217,6 +256,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'ralouphie/getallheaders' => array( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ralouphie/getallheaders', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'ramsey/collection' => array( 'pretty_version' => '2.1.1', 'version' => '2.1.1.0', @@ -428,9 +476,9 @@ 'dev_requirement' => false, ), 'zotlabs/hubzilla' => array( - 'pretty_version' => 'dev-10.2RC', - 'version' => 'dev-10.2RC', - 'reference' => '457cb748833f0f4926668a18974b6248dac462a7', + 'pretty_version' => 'dev-10.4RC', + 'version' => 'dev-10.4RC', + 'reference' => '7782183ae356db31dbef2dcf785ddc79c00335c1', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md new file mode 100644 index 000000000..a85929521 --- /dev/null +++ b/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -0,0 +1,475 @@ +# Change Log + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 2.7.1 - 2025-03-27 + +### Fixed + +- Fixed uppercase IPv6 addresses in URI + +### Changed + +- Improve uploaded file error message + +## 2.7.0 - 2024-07-18 + +### Added + +- Add `Utils::redactUserInfo()` method +- Add ability to encode bools as ints in `Query::build` + +## 2.6.3 - 2024-07-18 + +### Fixed + +- Make `StreamWrapper::stream_stat()` return `false` if inner stream's size is `null` + +### Changed + +- PHP 8.4 support + +## 2.6.2 - 2023-12-03 + +### Fixed + +- Fixed another issue with the fact that PHP transforms numeric strings in array keys to ints + +### Changed + +- Updated links in docs to their canonical versions +- Replaced `call_user_func*` with native calls + +## 2.6.1 - 2023-08-27 + +### Fixed + +- Properly handle the fact that PHP transforms numeric strings in array keys to ints + +## 2.6.0 - 2023-08-03 + +### Changed + +- Updated the mime type map to add some new entries, fix a couple of invalid entries, and remove an invalid entry +- Fallback to `application/octet-stream` if we are unable to guess the content type for a multipart file upload + +## 2.5.1 - 2023-08-03 + +### Fixed + +- Corrected mime type for `.acc` files to `audio/aac` + +### Changed + +- PHP 8.3 support + +## 2.5.0 - 2023-04-17 + +### Changed + +- Adjusted `psr/http-message` version constraint to `^1.1 || ^2.0` + +## 2.4.5 - 2023-04-17 + +### Fixed + +- Prevent possible warnings on unset variables in `ServerRequest::normalizeNestedFileSpec` +- Fixed `Message::bodySummary` when `preg_match` fails +- Fixed header validation issue + +## 2.4.4 - 2023-03-09 + +### Changed + +- Removed the need for `AllowDynamicProperties` in `LazyOpenStream` + +## 2.4.3 - 2022-10-26 + +### Changed + +- Replaced `sha1(uniqid())` by `bin2hex(random_bytes(20))` + +## 2.4.2 - 2022-10-25 + +### Fixed + +- Fixed erroneous behaviour when combining host and relative path + +## 2.4.1 - 2022-08-28 + +### Fixed + +- Rewind body before reading in `Message::bodySummary` + +## 2.4.0 - 2022-06-20 + +### Added + +- Added provisional PHP 8.2 support +- Added `UriComparator::isCrossOrigin` method + +## 2.3.0 - 2022-06-09 + +### Fixed + +- Added `Header::splitList` method +- Added `Utils::tryGetContents` method +- Improved `Stream::getContents` method +- Updated mimetype mappings + +## 2.2.2 - 2022-06-08 + +### Fixed + +- Fix `Message::parseRequestUri` for numeric headers +- Re-wrap exceptions thrown in `fread` into runtime exceptions +- Throw an exception when multipart options is misformatted + +## 2.2.1 - 2022-03-20 + +### Fixed + +- Correct header value validation + +## 2.2.0 - 2022-03-20 + +### Added + +- A more compressive list of mime types +- Add JsonSerializable to Uri +- Missing return types + +### Fixed + +- Bug MultipartStream no `uri` metadata +- Bug MultipartStream with filename for `data://` streams +- Fixed new line handling in MultipartStream +- Reduced RAM usage when copying streams +- Updated parsing in `Header::normalize()` + +## 2.1.1 - 2022-03-20 + +### Fixed + +- Validate header values properly + +## 2.1.0 - 2021-10-06 + +### Changed + +- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic + `InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former + for backwards compatibility. Callers relying on the exception being thrown to detect invalid + URIs should catch the new exception. + +### Fixed + +- Return `null` in caching stream size if remote size is `null` + +## 2.0.0 - 2021-06-30 + +Identical to the RC release. + +## 2.0.0@RC-1 - 2021-04-29 + +### Fixed + +- Handle possibly unset `url` in `stream_get_meta_data` + +## 2.0.0@beta-1 - 2021-03-21 + +### Added + +- PSR-17 factories +- Made classes final +- PHP7 type hints + +### Changed + +- When building a query string, booleans are represented as 1 and 0. + +### Removed + +- PHP < 7.2 support +- All functions in the `GuzzleHttp\Psr7` namespace + +## 1.8.1 - 2021-03-21 + +### Fixed + +- Issue parsing IPv6 URLs +- Issue modifying ServerRequest lost all its attributes + +## 1.8.0 - 2021-03-21 + +### Added + +- Locale independent URL parsing +- Most classes got a `@final` annotation to prepare for 2.0 + +### Fixed + +- Issue when creating stream from `php://input` and curl-ext is not installed +- Broken `Utils::tryFopen()` on PHP 8 + +## 1.7.0 - 2020-09-30 + +### Added + +- Replaced functions by static methods + +### Fixed + +- Converting a non-seekable stream to a string +- Handle multiple Set-Cookie correctly +- Ignore array keys in header values when merging +- Allow multibyte characters to be parsed in `Message:bodySummary()` + +### Changed + +- Restored partial HHVM 3 support + + +## [1.6.1] - 2019-07-02 + +### Fixed + +- Accept null and bool header values again + + +## [1.6.0] - 2019-06-30 + +### Added + +- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244) +- Added MIME type for WEBP image format (#246) +- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272) + +### Changed + +- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262) +- Accept port number 0 to be valid (#270) + +### Fixed + +- Fixed subsequent reads from `php://input` in ServerRequest (#247) +- Fixed readable/writable detection for certain stream modes (#248) +- Fixed encoding of special characters in the `userInfo` component of an URI (#253) + + +## [1.5.2] - 2018-12-04 + +### Fixed + +- Check body size when getting the message summary + + +## [1.5.1] - 2018-12-04 + +### Fixed + +- Get the summary of a body only if it is readable + + +## [1.5.0] - 2018-12-03 + +### Added + +- Response first-line to response string exception (fixes #145) +- A test for #129 behavior +- `get_message_body_summary` function in order to get the message summary +- `3gp` and `mkv` mime types + +### Changed + +- Clarify exception message when stream is detached + +### Deprecated + +- Deprecated parsing folded header lines as per RFC 7230 + +### Fixed + +- Fix `AppendStream::detach` to not close streams +- `InflateStream` preserves `isSeekable` attribute of the underlying stream +- `ServerRequest::getUriFromGlobals` to support URLs in query parameters + + +Several other fixes and improvements. + + +## [1.4.2] - 2017-03-20 + +### Fixed + +- Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing + calls to `trigger_error` when deprecated methods are invoked. + + +## [1.4.1] - 2017-02-27 + +### Added + +- Rriggering of silenced deprecation warnings. + +### Fixed + +- Reverted BC break by reintroducing behavior to automagically fix a URI with a + relative path and an authority by adding a leading slash to the path. It's only + deprecated now. + + +## [1.4.0] - 2017-02-21 + +### Added + +- Added common URI utility methods based on RFC 3986 (see documentation in the readme): + - `Uri::isDefaultPort` + - `Uri::isAbsolute` + - `Uri::isNetworkPathReference` + - `Uri::isAbsolutePathReference` + - `Uri::isRelativePathReference` + - `Uri::isSameDocumentReference` + - `Uri::composeComponents` + - `UriNormalizer::normalize` + - `UriNormalizer::isEquivalent` + - `UriResolver::relativize` + +### Changed + +- Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form. +- Allow `parse_response` to parse a response without delimiting space and reason. +- Ensure each URI modification results in a valid URI according to PSR-7 discussions. + Invalid modifications will throw an exception instead of returning a wrong URI or + doing some magic. + - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception + because the path of a URI with an authority must start with a slash "/" or be empty + - `(new Uri())->withScheme('http')` will return `'http://localhost'` + +### Deprecated + +- `Uri::resolve` in favor of `UriResolver::resolve` +- `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments` + +### Fixed + +- `Stream::read` when length parameter <= 0. +- `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory. +- `ServerRequest::getUriFromGlobals` when `Host` header contains port. +- Compatibility of URIs with `file` scheme and empty host. + + +## [1.3.1] - 2016-06-25 + +### Fixed + +- `Uri::__toString` for network path references, e.g. `//example.org`. +- Missing lowercase normalization for host. +- Handling of URI components in case they are `'0'` in a lot of places, + e.g. as a user info password. +- `Uri::withAddedHeader` to correctly merge headers with different case. +- Trimming of header values in `Uri::withAddedHeader`. Header values may + be surrounded by whitespace which should be ignored according to RFC 7230 + Section 3.2.4. This does not apply to header names. +- `Uri::withAddedHeader` with an array of header values. +- `Uri::resolve` when base path has no slash and handling of fragment. +- Handling of encoding in `Uri::with(out)QueryValue` so one can pass the + key/value both in encoded as well as decoded form to those methods. This is + consistent with withPath, withQuery etc. +- `ServerRequest::withoutAttribute` when attribute value is null. + + +## [1.3.0] - 2016-04-13 + +### Added + +- Remaining interfaces needed for full PSR7 compatibility + (ServerRequestInterface, UploadedFileInterface, etc.). +- Support for stream_for from scalars. + +### Changed + +- Can now extend Uri. + +### Fixed +- A bug in validating request methods by making it more permissive. + + +## [1.2.3] - 2016-02-18 + +### Fixed + +- Support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote + streams, which can sometimes return fewer bytes than requested with `fread`. +- Handling of gzipped responses with FNAME headers. + + +## [1.2.2] - 2016-01-22 + +### Added + +- Support for URIs without any authority. +- Support for HTTP 451 'Unavailable For Legal Reasons.' +- Support for using '0' as a filename. +- Support for including non-standard ports in Host headers. + + +## [1.2.1] - 2015-11-02 + +### Changes + +- Now supporting negative offsets when seeking to SEEK_END. + + +## [1.2.0] - 2015-08-15 + +### Changed + +- Body as `"0"` is now properly added to a response. +- Now allowing forward seeking in CachingStream. +- Now properly parsing HTTP requests that contain proxy targets in + `parse_request`. +- functions.php is now conditionally required. +- user-info is no longer dropped when resolving URIs. + + +## [1.1.0] - 2015-06-24 + +### Changed + +- URIs can now be relative. +- `multipart/form-data` headers are now overridden case-insensitively. +- URI paths no longer encode the following characters because they are allowed + in URIs: "(", ")", "*", "!", "'" +- A port is no longer added to a URI when the scheme is missing and no port is + present. + + +## 1.0.0 - 2015-05-19 + +Initial release. + +Currently unsupported: + +- `Psr\Http\Message\ServerRequestInterface` +- `Psr\Http\Message\UploadedFileInterface` + + + +[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0 +[1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2 +[1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1 +[1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0 +[1.4.2]: https://github.com/guzzle/psr7/compare/1.4.1...1.4.2 +[1.4.1]: https://github.com/guzzle/psr7/compare/1.4.0...1.4.1 +[1.4.0]: https://github.com/guzzle/psr7/compare/1.3.1...1.4.0 +[1.3.1]: https://github.com/guzzle/psr7/compare/1.3.0...1.3.1 +[1.3.0]: https://github.com/guzzle/psr7/compare/1.2.3...1.3.0 +[1.2.3]: https://github.com/guzzle/psr7/compare/1.2.2...1.2.3 +[1.2.2]: https://github.com/guzzle/psr7/compare/1.2.1...1.2.2 +[1.2.1]: https://github.com/guzzle/psr7/compare/1.2.0...1.2.1 +[1.2.0]: https://github.com/guzzle/psr7/compare/1.1.0...1.2.0 +[1.1.0]: https://github.com/guzzle/psr7/compare/1.0.0...1.1.0 diff --git a/vendor/guzzlehttp/psr7/LICENSE b/vendor/guzzlehttp/psr7/LICENSE new file mode 100644 index 000000000..51c7ec81c --- /dev/null +++ b/vendor/guzzlehttp/psr7/LICENSE @@ -0,0 +1,26 @@ +The MIT License (MIT) + +Copyright (c) 2015 Michael Dowling <mtdowling@gmail.com> +Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com> +Copyright (c) 2015 Graham Campbell <hello@gjcampbell.co.uk> +Copyright (c) 2016 Tobias Schultze <webmaster@tubo-world.de> +Copyright (c) 2016 George Mponos <gmponos@gmail.com> +Copyright (c) 2018 Tobias Nyholm <tobias.nyholm@gmail.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md new file mode 100644 index 000000000..2e9bb0b9b --- /dev/null +++ b/vendor/guzzlehttp/psr7/README.md @@ -0,0 +1,887 @@ +# PSR-7 Message Implementation + +This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/) +message implementation, several stream decorators, and some helpful +functionality like query string parsing. + + + + + +## Features + +This package comes with a number of stream implementations and stream +decorators. + + +## Installation + +```shell +composer require guzzlehttp/psr7 +``` + +## Version Guidance + +| Version | Status | PHP Version | +|---------|---------------------|--------------| +| 1.x | EOL (2024-06-30) | >=5.4,<8.2 | +| 2.x | Latest | >=7.2.5,<8.5 | + + +## AppendStream + +`GuzzleHttp\Psr7\AppendStream` + +Reads from multiple streams, one after the other. + +```php +use GuzzleHttp\Psr7; + +$a = Psr7\Utils::streamFor('abc, '); +$b = Psr7\Utils::streamFor('123.'); +$composed = new Psr7\AppendStream([$a, $b]); + +$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me')); + +echo $composed; // abc, 123. Above all listen to me. +``` + + +## BufferStream + +`GuzzleHttp\Psr7\BufferStream` + +Provides a buffer stream that can be written to fill a buffer, and read +from to remove bytes from the buffer. + +This stream returns a "hwm" metadata value that tells upstream consumers +what the configured high water mark of the stream is, or the maximum +preferred size of the buffer. + +```php +use GuzzleHttp\Psr7; + +// When more than 1024 bytes are in the buffer, it will begin returning +// false to writes. This is an indication that writers should slow down. +$buffer = new Psr7\BufferStream(1024); +``` + + +## CachingStream + +The CachingStream is used to allow seeking over previously read bytes on +non-seekable streams. This can be useful when transferring a non-seekable +entity body fails due to needing to rewind the stream (for example, resulting +from a redirect). Data that is read from the remote stream will be buffered in +a PHP temp stream so that previously read bytes are cached first in memory, +then on disk. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r')); +$stream = new Psr7\CachingStream($original); + +$stream->read(1024); +echo $stream->tell(); +// 1024 + +$stream->seek(0); +echo $stream->tell(); +// 0 +``` + + +## DroppingStream + +`GuzzleHttp\Psr7\DroppingStream` + +Stream decorator that begins dropping data once the size of the underlying +stream becomes too full. + +```php +use GuzzleHttp\Psr7; + +// Create an empty stream +$stream = Psr7\Utils::streamFor(); + +// Start dropping data when the stream has more than 10 bytes +$dropping = new Psr7\DroppingStream($stream, 10); + +$dropping->write('01234567890123456789'); +echo $stream; // 0123456789 +``` + + +## FnStream + +`GuzzleHttp\Psr7\FnStream` + +Compose stream implementations based on a hash of functions. + +Allows for easy testing and extension of a provided stream without needing +to create a concrete class for a simple extension point. + +```php + +use GuzzleHttp\Psr7; + +$stream = Psr7\Utils::streamFor('hi'); +$fnStream = Psr7\FnStream::decorate($stream, [ + 'rewind' => function () use ($stream) { + echo 'About to rewind - '; + $stream->rewind(); + echo 'rewound!'; + } +]); + +$fnStream->rewind(); +// Outputs: About to rewind - rewound! +``` + + +## InflateStream + +`GuzzleHttp\Psr7\InflateStream` + +Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content. + +This stream decorator converts the provided stream to a PHP stream resource, +then appends the zlib.inflate filter. The stream is then converted back +to a Guzzle stream resource to be used as a Guzzle stream. + + +## LazyOpenStream + +`GuzzleHttp\Psr7\LazyOpenStream` + +Lazily reads or writes to a file that is opened only after an IO operation +take place on the stream. + +```php +use GuzzleHttp\Psr7; + +$stream = new Psr7\LazyOpenStream('/path/to/file', 'r'); +// The file has not yet been opened... + +echo $stream->read(10); +// The file is opened and read from only when needed. +``` + + +## LimitStream + +`GuzzleHttp\Psr7\LimitStream` + +LimitStream can be used to read a subset or slice of an existing stream object. +This can be useful for breaking a large file into smaller pieces to be sent in +chunks (e.g. Amazon S3's multipart upload API). + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+')); +echo $original->getSize(); +// >>> 1048576 + +// Limit the size of the body to 1024 bytes and start reading from byte 2048 +$stream = new Psr7\LimitStream($original, 1024, 2048); +echo $stream->getSize(); +// >>> 1024 +echo $stream->tell(); +// >>> 0 +``` + + +## MultipartStream + +`GuzzleHttp\Psr7\MultipartStream` + +Stream that when read returns bytes for a streaming multipart or +multipart/form-data stream. + + +## NoSeekStream + +`GuzzleHttp\Psr7\NoSeekStream` + +NoSeekStream wraps a stream and does not allow seeking. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor('foo'); +$noSeek = new Psr7\NoSeekStream($original); + +echo $noSeek->read(3); +// foo +var_export($noSeek->isSeekable()); +// false +$noSeek->seek(0); +var_export($noSeek->read(3)); +// NULL +``` + + +## PumpStream + +`GuzzleHttp\Psr7\PumpStream` + +Provides a read only stream that pumps data from a PHP callable. + +When invoking the provided callable, the PumpStream will pass the amount of +data requested to read to the callable. The callable can choose to ignore +this value and return fewer or more bytes than requested. Any extra data +returned by the provided callable is buffered internally until drained using +the read() function of the PumpStream. The provided callable MUST return +false when there is no more data to read. + + +## Implementing stream decorators + +Creating a stream decorator is very easy thanks to the +`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that +implement `Psr\Http\Message\StreamInterface` by proxying to an underlying +stream. Just `use` the `StreamDecoratorTrait` and implement your custom +methods. + +For example, let's say we wanted to call a specific function each time the last +byte is read from a stream. This could be implemented by overriding the +`read()` method. + +```php +use Psr\Http\Message\StreamInterface; +use GuzzleHttp\Psr7\StreamDecoratorTrait; + +class EofCallbackStream implements StreamInterface +{ + use StreamDecoratorTrait; + + private $callback; + + private $stream; + + public function __construct(StreamInterface $stream, callable $cb) + { + $this->stream = $stream; + $this->callback = $cb; + } + + public function read($length) + { + $result = $this->stream->read($length); + + // Invoke the callback when EOF is hit. + if ($this->eof()) { + ($this->callback)(); + } + + return $result; + } +} +``` + +This decorator could be added to any existing stream and used like so: + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor('foo'); + +$eofStream = new EofCallbackStream($original, function () { + echo 'EOF!'; +}); + +$eofStream->read(2); +$eofStream->read(1); +// echoes "EOF!" +$eofStream->seek(0); +$eofStream->read(3); +// echoes "EOF!" +``` + + +## PHP StreamWrapper + +You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a +PSR-7 stream as a PHP stream resource. + +Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP +stream from a PSR-7 stream. + +```php +use GuzzleHttp\Psr7\StreamWrapper; + +$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!'); +$resource = StreamWrapper::getResource($stream); +echo fread($resource, 6); // outputs hello! +``` + + +# Static API + +There are various static methods available under the `GuzzleHttp\Psr7` namespace. + + +## `GuzzleHttp\Psr7\Message::toString` + +`public static function toString(MessageInterface $message): string` + +Returns the string representation of an HTTP message. + +```php +$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); +echo GuzzleHttp\Psr7\Message::toString($request); +``` + + +## `GuzzleHttp\Psr7\Message::bodySummary` + +`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null` + +Get a short summary of the message body. + +Will return `null` if the response is not printable. + + +## `GuzzleHttp\Psr7\Message::rewindBody` + +`public static function rewindBody(MessageInterface $message): void` + +Attempts to rewind a message body and throws an exception on failure. + +The body of the message will only be rewound if a call to `tell()` +returns a value other than `0`. + + +## `GuzzleHttp\Psr7\Message::parseMessage` + +`public static function parseMessage(string $message): array` + +Parses an HTTP message into an associative array. + +The array contains the "start-line" key containing the start line of +the message, "headers" key containing an associative array of header +array values, and a "body" key containing the body of the message. + + +## `GuzzleHttp\Psr7\Message::parseRequestUri` + +`public static function parseRequestUri(string $path, array $headers): string` + +Constructs a URI for an HTTP request message. + + +## `GuzzleHttp\Psr7\Message::parseRequest` + +`public static function parseRequest(string $message): Request` + +Parses a request message string into a request object. + + +## `GuzzleHttp\Psr7\Message::parseResponse` + +`public static function parseResponse(string $message): Response` + +Parses a response message string into a response object. + + +## `GuzzleHttp\Psr7\Header::parse` + +`public static function parse(string|array $header): array` + +Parse an array of header values containing ";" separated data into an +array of associative arrays representing the header key value pair data +of the header. When a parameter does not contain a value, but just +contains a key, this function will inject a key with a '' string value. + + +## `GuzzleHttp\Psr7\Header::splitList` + +`public static function splitList(string|string[] $header): string[]` + +Splits a HTTP header defined to contain a comma-separated list into +each individual value: + +``` +$knownEtags = Header::splitList($request->getHeader('if-none-match')); +``` + +Example headers include `accept`, `cache-control` and `if-none-match`. + + +## `GuzzleHttp\Psr7\Header::normalize` (deprecated) + +`public static function normalize(string|array $header): array` + +`Header::normalize()` is deprecated in favor of [`Header::splitList()`](README.md#guzzlehttppsr7headersplitlist) +which performs the same operation with a cleaned up API and improved +documentation. + +Converts an array of header values that may contain comma separated +headers into an array of headers with no comma separated values. + + +## `GuzzleHttp\Psr7\Query::parse` + +`public static function parse(string $str, int|bool $urlEncoding = true): array` + +Parse a query string into an associative array. + +If multiple values are found for the same key, the value of that key +value pair will become an array. This function does not parse nested +PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2` +will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`. + + +## `GuzzleHttp\Psr7\Query::build` + +`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986, bool $treatBoolsAsInts = true): string` + +Build a query string from an array of key value pairs. + +This function can use the return value of `parse()` to build a query +string. This function does not modify the provided keys when an array is +encountered (like `http_build_query()` would). + + +## `GuzzleHttp\Psr7\Utils::caselessRemove` + +`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array` + +Remove the items given by the keys, case insensitively from the data. + + +## `GuzzleHttp\Psr7\Utils::copyToStream` + +`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void` + +Copy the contents of a stream into another stream until the given number +of bytes have been read. + + +## `GuzzleHttp\Psr7\Utils::copyToString` + +`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string` + +Copy the contents of a stream into a string until the given number of +bytes have been read. + + +## `GuzzleHttp\Psr7\Utils::hash` + +`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string` + +Calculate a hash of a stream. + +This method reads the entire stream to calculate a rolling hash, based on +PHP's `hash_init` functions. + + +## `GuzzleHttp\Psr7\Utils::modifyRequest` + +`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface` + +Clone and modify a request with the given changes. + +This method is useful for reducing the number of clones needed to mutate +a message. + +- method: (string) Changes the HTTP method. +- set_headers: (array) Sets the given headers. +- remove_headers: (array) Remove the given headers. +- body: (mixed) Sets the given body. +- uri: (UriInterface) Set the URI. +- query: (string) Set the query string value of the URI. +- version: (string) Set the protocol version. + + +## `GuzzleHttp\Psr7\Utils::readLine` + +`public static function readLine(StreamInterface $stream, ?int $maxLength = null): string` + +Read a line from the stream up to the maximum allowed buffer length. + + +## `GuzzleHttp\Psr7\Utils::redactUserInfo` + +`public static function redactUserInfo(UriInterface $uri): UriInterface` + +Redact the password in the user info part of a URI. + + +## `GuzzleHttp\Psr7\Utils::streamFor` + +`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface` + +Create a new stream based on the input type. + +Options is an associative array that can contain the following keys: + +- metadata: Array of custom metadata. +- size: Size of the stream. + +This method accepts the following `$resource` types: + +- `Psr\Http\Message\StreamInterface`: Returns the value as-is. +- `string`: Creates a stream object that uses the given string as the contents. +- `resource`: Creates a stream object that wraps the given PHP stream resource. +- `Iterator`: If the provided value implements `Iterator`, then a read-only + stream object will be created that wraps the given iterable. Each time the + stream is read from, data from the iterator will fill a buffer and will be + continuously called until the buffer is equal to the requested read size. + Subsequent read calls will first read from the buffer and then call `next` + on the underlying iterator until it is exhausted. +- `object` with `__toString()`: If the object has the `__toString()` method, + the object will be cast to a string and then a stream will be returned that + uses the string value. +- `NULL`: When `null` is passed, an empty stream object is returned. +- `callable` When a callable is passed, a read-only stream object will be + created that invokes the given callable. The callable is invoked with the + number of suggested bytes to read. The callable can return any number of + bytes, but MUST return `false` when there is no more data to return. The + stream object that wraps the callable will invoke the callable until the + number of requested bytes are available. Any additional bytes will be + buffered and used in subsequent reads. + +```php +$stream = GuzzleHttp\Psr7\Utils::streamFor('foo'); +$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r')); + +$generator = function ($bytes) { + for ($i = 0; $i < $bytes; $i++) { + yield ' '; + } +} + +$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100)); +``` + + +## `GuzzleHttp\Psr7\Utils::tryFopen` + +`public static function tryFopen(string $filename, string $mode): resource` + +Safely opens a PHP stream resource using a filename. + +When fopen fails, PHP normally raises a warning. This function adds an +error handler that checks for errors and throws an exception instead. + + +## `GuzzleHttp\Psr7\Utils::tryGetContents` + +`public static function tryGetContents(resource $stream): string` + +Safely gets the contents of a given stream. + +When stream_get_contents fails, PHP normally raises a warning. This +function adds an error handler that checks for errors and throws an +exception instead. + + +## `GuzzleHttp\Psr7\Utils::uriFor` + +`public static function uriFor(string|UriInterface $uri): UriInterface` + +Returns a UriInterface for the given value. + +This function accepts a string or UriInterface and returns a +UriInterface for the given value. If the value is already a +UriInterface, it is returned as-is. + + +## `GuzzleHttp\Psr7\MimeType::fromFilename` + +`public static function fromFilename(string $filename): string|null` + +Determines the mimetype of a file by looking at its extension. + + +## `GuzzleHttp\Psr7\MimeType::fromExtension` + +`public static function fromExtension(string $extension): string|null` + +Maps a file extensions to a mimetype. + + +## Upgrading from Function API + +The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience: + +| Original Function | Replacement Method | +|----------------|----------------| +| `str` | `Message::toString` | +| `uri_for` | `Utils::uriFor` | +| `stream_for` | `Utils::streamFor` | +| `parse_header` | `Header::parse` | +| `normalize_header` | `Header::normalize` | +| `modify_request` | `Utils::modifyRequest` | +| `rewind_body` | `Message::rewindBody` | +| `try_fopen` | `Utils::tryFopen` | +| `copy_to_string` | `Utils::copyToString` | +| `copy_to_stream` | `Utils::copyToStream` | +| `hash` | `Utils::hash` | +| `readline` | `Utils::readLine` | +| `parse_request` | `Message::parseRequest` | +| `parse_response` | `Message::parseResponse` | +| `parse_query` | `Query::parse` | +| `build_query` | `Query::build` | +| `mimetype_from_filename` | `MimeType::fromFilename` | +| `mimetype_from_extension` | `MimeType::fromExtension` | +| `_parse_message` | `Message::parseMessage` | +| `_parse_request_uri` | `Message::parseRequestUri` | +| `get_message_body_summary` | `Message::bodySummary` | +| `_caseless_remove` | `Utils::caselessRemove` | + + +# Additional URI Methods + +Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class, +this library also provides additional functionality when working with URIs as static methods. + +## URI Types + +An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference. +An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, +the base URI. Relative references can be divided into several forms according to +[RFC 3986 Section 4.2](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2): + +- network-path references, e.g. `//example.com/path` +- absolute-path references, e.g. `/path` +- relative-path references, e.g. `subpath` + +The following methods can be used to identify the type of the URI. + +### `GuzzleHttp\Psr7\Uri::isAbsolute` + +`public static function isAbsolute(UriInterface $uri): bool` + +Whether the URI is absolute, i.e. it has a scheme. + +### `GuzzleHttp\Psr7\Uri::isNetworkPathReference` + +`public static function isNetworkPathReference(UriInterface $uri): bool` + +Whether the URI is a network-path reference. A relative reference that begins with two slash characters is +termed an network-path reference. + +### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference` + +`public static function isAbsolutePathReference(UriInterface $uri): bool` + +Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is +termed an absolute-path reference. + +### `GuzzleHttp\Psr7\Uri::isRelativePathReference` + +`public static function isRelativePathReference(UriInterface $uri): bool` + +Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is +termed a relative-path reference. + +### `GuzzleHttp\Psr7\Uri::isSameDocumentReference` + +`public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool` + +Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its +fragment component, identical to the base URI. When no base URI is given, only an empty URI reference +(apart from its fragment) is considered a same-document reference. + +## URI Components + +Additional methods to work with URI components. + +### `GuzzleHttp\Psr7\Uri::isDefaultPort` + +`public static function isDefaultPort(UriInterface $uri): bool` + +Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null +or the standard port. This method can be used independently of the implementation. + +### `GuzzleHttp\Psr7\Uri::composeComponents` + +`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string` + +Composes a URI reference string from its various components according to +[RFC 3986 Section 5.3](https://datatracker.ietf.org/doc/html/rfc3986#section-5.3). Usually this method does not need +to be called manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`. + +### `GuzzleHttp\Psr7\Uri::fromParts` + +`public static function fromParts(array $parts): UriInterface` + +Creates a URI from a hash of [`parse_url`](https://www.php.net/manual/en/function.parse-url.php) components. + + +### `GuzzleHttp\Psr7\Uri::withQueryValue` + +`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface` + +Creates a new URI with a specific query string value. Any existing query string values that exactly match the +provided key are removed and replaced with the given key value pair. A value of null will set the query string +key without a value, e.g. "key" instead of "key=value". + +### `GuzzleHttp\Psr7\Uri::withQueryValues` + +`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface` + +Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an +associative array of key => value. + +### `GuzzleHttp\Psr7\Uri::withoutQueryValue` + +`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface` + +Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the +provided key are removed. + +## Cross-Origin Detection + +`GuzzleHttp\Psr7\UriComparator` provides methods to determine if a modified URL should be considered cross-origin. + +### `GuzzleHttp\Psr7\UriComparator::isCrossOrigin` + +`public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool` + +Determines if a modified URL should be considered cross-origin with respect to an original URL. + +## Reference Resolution + +`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according +to [RFC 3986 Section 5](https://datatracker.ietf.org/doc/html/rfc3986#section-5). This is for example also what web +browsers do when resolving a link in a website based on the current request URI. + +### `GuzzleHttp\Psr7\UriResolver::resolve` + +`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface` + +Converts the relative URI into a new URI that is resolved against the base URI. + +### `GuzzleHttp\Psr7\UriResolver::removeDotSegments` + +`public static function removeDotSegments(string $path): string` + +Removes dot segments from a path and returns the new path according to +[RFC 3986 Section 5.2.4](https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4). + +### `GuzzleHttp\Psr7\UriResolver::relativize` + +`public static function relativize(UriInterface $base, UriInterface $target): UriInterface` + +Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve(): + +```php +(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) +``` + +One use-case is to use the current request URI as base URI and then generate relative links in your documents +to reduce the document size or offer self-contained downloadable document archives. + +```php +$base = new Uri('http://example.com/a/b/'); +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. +echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. +``` + +## Normalization and Comparison + +`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to +[RFC 3986 Section 6](https://datatracker.ietf.org/doc/html/rfc3986#section-6). + +### `GuzzleHttp\Psr7\UriNormalizer::normalize` + +`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface` + +Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. +This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask +of normalizations to apply. The following normalizations are available: + +- `UriNormalizer::PRESERVING_NORMALIZATIONS` + + Default normalizations which only include the ones that preserve semantics. + +- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING` + + All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. + + Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b` + +- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS` + + Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of + ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should + not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved + characters by URI normalizers. + + Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/` + +- `UriNormalizer::CONVERT_EMPTY_PATH` + + Converts the empty path to "/" for http and https URIs. + + Example: `http://example.org` → `http://example.org/` + +- `UriNormalizer::REMOVE_DEFAULT_HOST` + + Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host + "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to + RFC 3986. + + Example: `file://localhost/myfile` → `file:///myfile` + +- `UriNormalizer::REMOVE_DEFAULT_PORT` + + Removes the default port of the given URI scheme from the URI. + + Example: `http://example.org:80/` → `http://example.org/` + +- `UriNormalizer::REMOVE_DOT_SEGMENTS` + + Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would + change the semantics of the URI reference. + + Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html` + +- `UriNormalizer::REMOVE_DUPLICATE_SLASHES` + + Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes + and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization + may change the semantics. Encoded slashes (%2F) are not removed. + + Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html` + +- `UriNormalizer::SORT_QUERY_PARAMETERS` + + Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be + significant (this is not defined by the standard). So this normalization is not safe and may change the semantics + of the URI. + + Example: `?lang=en&article=fred` → `?article=fred&lang=en` + +### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent` + +`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool` + +Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given +`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent. +This of course assumes they will be resolved against the same base URI. If this is not the case, determination of +equivalence or difference of relative references does not mean anything. + + +## Security + +If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information. + + +## License + +Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information. + + +## For Enterprise + +Available as part of the Tidelift Subscription + +The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-psr7?utm_source=packagist-guzzlehttp-psr7&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json new file mode 100644 index 000000000..28d15f571 --- /dev/null +++ b/vendor/guzzlehttp/psr7/composer.json @@ -0,0 +1,93 @@ +{ + "name": "guzzlehttp/psr7", + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "request", + "response", + "message", + "stream", + "http", + "uri", + "url", + "psr-7" + ], + "license": "MIT", + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "GuzzleHttp\\Tests\\Psr7\\": "tests/" + } + }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, + "preferred-install": "dist", + "sort-packages": true + } +} diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php new file mode 100644 index 000000000..ee8f37882 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/AppendStream.php @@ -0,0 +1,248 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Reads from multiple streams, one after the other. + * + * This is a read-only stream decorator. + */ +final class AppendStream implements StreamInterface +{ + /** @var StreamInterface[] Streams being decorated */ + private $streams = []; + + /** @var bool */ + private $seekable = true; + + /** @var int */ + private $current = 0; + + /** @var int */ + private $pos = 0; + + /** + * @param StreamInterface[] $streams Streams to decorate. Each stream must + * be readable. + */ + public function __construct(array $streams = []) + { + foreach ($streams as $stream) { + $this->addStream($stream); + } + } + + public function __toString(): string + { + try { + $this->rewind(); + + return $this->getContents(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + /** + * Add a stream to the AppendStream + * + * @param StreamInterface $stream Stream to append. Must be readable. + * + * @throws \InvalidArgumentException if the stream is not readable + */ + public function addStream(StreamInterface $stream): void + { + if (!$stream->isReadable()) { + throw new \InvalidArgumentException('Each stream must be readable'); + } + + // The stream is only seekable if all streams are seekable + if (!$stream->isSeekable()) { + $this->seekable = false; + } + + $this->streams[] = $stream; + } + + public function getContents(): string + { + return Utils::copyToString($this); + } + + /** + * Closes each attached stream. + */ + public function close(): void + { + $this->pos = $this->current = 0; + $this->seekable = true; + + foreach ($this->streams as $stream) { + $stream->close(); + } + + $this->streams = []; + } + + /** + * Detaches each attached stream. + * + * Returns null as it's not clear which underlying stream resource to return. + */ + public function detach() + { + $this->pos = $this->current = 0; + $this->seekable = true; + + foreach ($this->streams as $stream) { + $stream->detach(); + } + + $this->streams = []; + + return null; + } + + public function tell(): int + { + return $this->pos; + } + + /** + * Tries to calculate the size by adding the size of each stream. + * + * If any of the streams do not return a valid number, then the size of the + * append stream cannot be determined and null is returned. + */ + public function getSize(): ?int + { + $size = 0; + + foreach ($this->streams as $stream) { + $s = $stream->getSize(); + if ($s === null) { + return null; + } + $size += $s; + } + + return $size; + } + + public function eof(): bool + { + return !$this->streams + || ($this->current >= count($this->streams) - 1 + && $this->streams[$this->current]->eof()); + } + + public function rewind(): void + { + $this->seek(0); + } + + /** + * Attempts to seek to the given position. Only supports SEEK_SET. + */ + public function seek($offset, $whence = SEEK_SET): void + { + if (!$this->seekable) { + throw new \RuntimeException('This AppendStream is not seekable'); + } elseif ($whence !== SEEK_SET) { + throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); + } + + $this->pos = $this->current = 0; + + // Rewind each stream + foreach ($this->streams as $i => $stream) { + try { + $stream->rewind(); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to seek stream ' + .$i.' of the AppendStream', 0, $e); + } + } + + // Seek to the actual position by reading from each stream + while ($this->pos < $offset && !$this->eof()) { + $result = $this->read(min(8096, $offset - $this->pos)); + if ($result === '') { + break; + } + } + } + + /** + * Reads from all of the appended streams until the length is met or EOF. + */ + public function read($length): string + { + $buffer = ''; + $total = count($this->streams) - 1; + $remaining = $length; + $progressToNext = false; + + while ($remaining > 0) { + // Progress to the next stream if needed. + if ($progressToNext || $this->streams[$this->current]->eof()) { + $progressToNext = false; + if ($this->current === $total) { + break; + } + ++$this->current; + } + + $result = $this->streams[$this->current]->read($remaining); + + if ($result === '') { + $progressToNext = true; + continue; + } + + $buffer .= $result; + $remaining = $length - strlen($buffer); + } + + $this->pos += strlen($buffer); + + return $buffer; + } + + public function isReadable(): bool + { + return true; + } + + public function isWritable(): bool + { + return false; + } + + public function isSeekable(): bool + { + return $this->seekable; + } + + public function write($string): int + { + throw new \RuntimeException('Cannot write to an AppendStream'); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + return $key ? null : []; + } +} diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php new file mode 100644 index 000000000..2b0eb77be --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/BufferStream.php @@ -0,0 +1,147 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Provides a buffer stream that can be written to to fill a buffer, and read + * from to remove bytes from the buffer. + * + * This stream returns a "hwm" metadata value that tells upstream consumers + * what the configured high water mark of the stream is, or the maximum + * preferred size of the buffer. + */ +final class BufferStream implements StreamInterface +{ + /** @var int */ + private $hwm; + + /** @var string */ + private $buffer = ''; + + /** + * @param int $hwm High water mark, representing the preferred maximum + * buffer size. If the size of the buffer exceeds the high + * water mark, then calls to write will continue to succeed + * but will return 0 to inform writers to slow down + * until the buffer has been drained by reading from it. + */ + public function __construct(int $hwm = 16384) + { + $this->hwm = $hwm; + } + + public function __toString(): string + { + return $this->getContents(); + } + + public function getContents(): string + { + $buffer = $this->buffer; + $this->buffer = ''; + + return $buffer; + } + + public function close(): void + { + $this->buffer = ''; + } + + public function detach() + { + $this->close(); + + return null; + } + + public function getSize(): ?int + { + return strlen($this->buffer); + } + + public function isReadable(): bool + { + return true; + } + + public function isWritable(): bool + { + return true; + } + + public function isSeekable(): bool + { + return false; + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + throw new \RuntimeException('Cannot seek a BufferStream'); + } + + public function eof(): bool + { + return strlen($this->buffer) === 0; + } + + public function tell(): int + { + throw new \RuntimeException('Cannot determine the position of a BufferStream'); + } + + /** + * Reads data from the buffer. + */ + public function read($length): string + { + $currentLength = strlen($this->buffer); + + if ($length >= $currentLength) { + // No need to slice the buffer because we don't have enough data. + $result = $this->buffer; + $this->buffer = ''; + } else { + // Slice up the result to provide a subset of the buffer. + $result = substr($this->buffer, 0, $length); + $this->buffer = substr($this->buffer, $length); + } + + return $result; + } + + /** + * Writes data to the buffer. + */ + public function write($string): int + { + $this->buffer .= $string; + + if (strlen($this->buffer) >= $this->hwm) { + return 0; + } + + return strlen($string); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + if ($key === 'hwm') { + return $this->hwm; + } + + return $key ? null : []; + } +} diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php new file mode 100644 index 000000000..7e4554d5c --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -0,0 +1,153 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator that can cache previously read bytes from a sequentially + * read stream. + */ +final class CachingStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var StreamInterface Stream being wrapped */ + private $remoteStream; + + /** @var int Number of bytes to skip reading due to a write on the buffer */ + private $skipReadBytes = 0; + + /** + * @var StreamInterface + */ + private $stream; + + /** + * We will treat the buffer object as the body of the stream + * + * @param StreamInterface $stream Stream to cache. The cursor is assumed to be at the beginning of the stream. + * @param StreamInterface $target Optionally specify where data is cached + */ + public function __construct( + StreamInterface $stream, + ?StreamInterface $target = null + ) { + $this->remoteStream = $stream; + $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+')); + } + + public function getSize(): ?int + { + $remoteSize = $this->remoteStream->getSize(); + + if (null === $remoteSize) { + return null; + } + + return max($this->stream->getSize(), $remoteSize); + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + if ($whence === SEEK_SET) { + $byte = $offset; + } elseif ($whence === SEEK_CUR) { + $byte = $offset + $this->tell(); + } elseif ($whence === SEEK_END) { + $size = $this->remoteStream->getSize(); + if ($size === null) { + $size = $this->cacheEntireStream(); + } + $byte = $size + $offset; + } else { + throw new \InvalidArgumentException('Invalid whence'); + } + + $diff = $byte - $this->stream->getSize(); + + if ($diff > 0) { + // Read the remoteStream until we have read in at least the amount + // of bytes requested, or we reach the end of the file. + while ($diff > 0 && !$this->remoteStream->eof()) { + $this->read($diff); + $diff = $byte - $this->stream->getSize(); + } + } else { + // We can just do a normal seek since we've already seen this byte. + $this->stream->seek($byte); + } + } + + public function read($length): string + { + // Perform a regular read on any previously read data from the buffer + $data = $this->stream->read($length); + $remaining = $length - strlen($data); + + // More data was requested so read from the remote stream + if ($remaining) { + // If data was written to the buffer in a position that would have + // been filled from the remote stream, then we must skip bytes on + // the remote stream to emulate overwriting bytes from that + // position. This mimics the behavior of other PHP stream wrappers. + $remoteData = $this->remoteStream->read( + $remaining + $this->skipReadBytes + ); + + if ($this->skipReadBytes) { + $len = strlen($remoteData); + $remoteData = substr($remoteData, $this->skipReadBytes); + $this->skipReadBytes = max(0, $this->skipReadBytes - $len); + } + + $data .= $remoteData; + $this->stream->write($remoteData); + } + + return $data; + } + + public function write($string): int + { + // When appending to the end of the currently read stream, you'll want + // to skip bytes from being read from the remote stream to emulate + // other stream wrappers. Basically replacing bytes of data of a fixed + // length. + $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); + if ($overflow > 0) { + $this->skipReadBytes += $overflow; + } + + return $this->stream->write($string); + } + + public function eof(): bool + { + return $this->stream->eof() && $this->remoteStream->eof(); + } + + /** + * Close both the remote stream and buffer stream + */ + public function close(): void + { + $this->remoteStream->close(); + $this->stream->close(); + } + + private function cacheEntireStream(): int + { + $target = new FnStream(['write' => 'strlen']); + Utils::copyToStream($this, $target); + + return $this->tell(); + } +} diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php new file mode 100644 index 000000000..6e3d209d0 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/DroppingStream.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator that begins dropping data once the size of the underlying + * stream becomes too full. + */ +final class DroppingStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var int */ + private $maxLength; + + /** @var StreamInterface */ + private $stream; + + /** + * @param StreamInterface $stream Underlying stream to decorate. + * @param int $maxLength Maximum size before dropping data. + */ + public function __construct(StreamInterface $stream, int $maxLength) + { + $this->stream = $stream; + $this->maxLength = $maxLength; + } + + public function write($string): int + { + $diff = $this->maxLength - $this->stream->getSize(); + + // Begin returning 0 when the underlying stream is too large. + if ($diff <= 0) { + return 0; + } + + // Write the stream or a subset of the stream if needed. + if (strlen($string) < $diff) { + return $this->stream->write($string); + } + + return $this->stream->write(substr($string, 0, $diff)); + } +} diff --git a/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php new file mode 100644 index 000000000..3a084779a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php @@ -0,0 +1,14 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7\Exception; + +use InvalidArgumentException; + +/** + * Exception thrown if a URI cannot be parsed because it's malformed. + */ +class MalformedUriException extends InvalidArgumentException +{ +} diff --git a/vendor/guzzlehttp/psr7/src/FnStream.php b/vendor/guzzlehttp/psr7/src/FnStream.php new file mode 100644 index 000000000..9e6a7f31a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/FnStream.php @@ -0,0 +1,180 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Compose stream implementations based on a hash of functions. + * + * Allows for easy testing and extension of a provided stream without needing + * to create a concrete class for a simple extension point. + */ +#[\AllowDynamicProperties] +final class FnStream implements StreamInterface +{ + private const SLOTS = [ + '__toString', 'close', 'detach', 'rewind', + 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', + 'isReadable', 'read', 'getContents', 'getMetadata', + ]; + + /** @var array<string, callable> */ + private $methods; + + /** + * @param array<string, callable> $methods Hash of method name to a callable. + */ + public function __construct(array $methods) + { + $this->methods = $methods; + + // Create the functions on the class + foreach ($methods as $name => $fn) { + $this->{'_fn_'.$name} = $fn; + } + } + + /** + * Lazily determine which methods are not implemented. + * + * @throws \BadMethodCallException + */ + public function __get(string $name): void + { + throw new \BadMethodCallException(str_replace('_fn_', '', $name) + .'() is not implemented in the FnStream'); + } + + /** + * The close method is called on the underlying stream only if possible. + */ + public function __destruct() + { + if (isset($this->_fn_close)) { + ($this->_fn_close)(); + } + } + + /** + * An unserialize would allow the __destruct to run when the unserialized value goes out of scope. + * + * @throws \LogicException + */ + public function __wakeup(): void + { + throw new \LogicException('FnStream should never be unserialized'); + } + + /** + * Adds custom functionality to an underlying stream by intercepting + * specific method calls. + * + * @param StreamInterface $stream Stream to decorate + * @param array<string, callable> $methods Hash of method name to a closure + * + * @return FnStream + */ + public static function decorate(StreamInterface $stream, array $methods) + { + // If any of the required methods were not provided, then simply + // proxy to the decorated stream. + foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) { + /** @var callable $callable */ + $callable = [$stream, $diff]; + $methods[$diff] = $callable; + } + + return new self($methods); + } + + public function __toString(): string + { + try { + /** @var string */ + return ($this->_fn___toString)(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function close(): void + { + ($this->_fn_close)(); + } + + public function detach() + { + return ($this->_fn_detach)(); + } + + public function getSize(): ?int + { + return ($this->_fn_getSize)(); + } + + public function tell(): int + { + return ($this->_fn_tell)(); + } + + public function eof(): bool + { + return ($this->_fn_eof)(); + } + + public function isSeekable(): bool + { + return ($this->_fn_isSeekable)(); + } + + public function rewind(): void + { + ($this->_fn_rewind)(); + } + + public function seek($offset, $whence = SEEK_SET): void + { + ($this->_fn_seek)($offset, $whence); + } + + public function isWritable(): bool + { + return ($this->_fn_isWritable)(); + } + + public function write($string): int + { + return ($this->_fn_write)($string); + } + + public function isReadable(): bool + { + return ($this->_fn_isReadable)(); + } + + public function read($length): string + { + return ($this->_fn_read)($length); + } + + public function getContents(): string + { + return ($this->_fn_getContents)(); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + return ($this->_fn_getMetadata)($key); + } +} diff --git a/vendor/guzzlehttp/psr7/src/Header.php b/vendor/guzzlehttp/psr7/src/Header.php new file mode 100644 index 000000000..bbce8b03d --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Header.php @@ -0,0 +1,134 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +final class Header +{ + /** + * Parse an array of header values containing ";" separated data into an + * array of associative arrays representing the header key value pair data + * of the header. When a parameter does not contain a value, but just + * contains a key, this function will inject a key with a '' string value. + * + * @param string|array $header Header to parse into components. + */ + public static function parse($header): array + { + static $trimmed = "\"' \n\t\r"; + $params = $matches = []; + + foreach ((array) $header as $value) { + foreach (self::splitList($value) as $val) { + $part = []; + foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) ?: [] as $kvp) { + if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { + $m = $matches[0]; + if (isset($m[1])) { + $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); + } else { + $part[] = trim($m[0], $trimmed); + } + } + } + if ($part) { + $params[] = $part; + } + } + } + + return $params; + } + + /** + * Converts an array of header values that may contain comma separated + * headers into an array of headers with no comma separated values. + * + * @param string|array $header Header to normalize. + * + * @deprecated Use self::splitList() instead. + */ + public static function normalize($header): array + { + $result = []; + foreach ((array) $header as $value) { + foreach (self::splitList($value) as $parsed) { + $result[] = $parsed; + } + } + + return $result; + } + + /** + * Splits a HTTP header defined to contain a comma-separated list into + * each individual value. Empty values will be removed. + * + * Example headers include 'accept', 'cache-control' and 'if-none-match'. + * + * This method must not be used to parse headers that are not defined as + * a list, such as 'user-agent' or 'set-cookie'. + * + * @param string|string[] $values Header value as returned by MessageInterface::getHeader() + * + * @return string[] + */ + public static function splitList($values): array + { + if (!\is_array($values)) { + $values = [$values]; + } + + $result = []; + foreach ($values as $value) { + if (!\is_string($value)) { + throw new \TypeError('$header must either be a string or an array containing strings.'); + } + + $v = ''; + $isQuoted = false; + $isEscaped = false; + for ($i = 0, $max = \strlen($value); $i < $max; ++$i) { + if ($isEscaped) { + $v .= $value[$i]; + $isEscaped = false; + + continue; + } + + if (!$isQuoted && $value[$i] === ',') { + $v = \trim($v); + if ($v !== '') { + $result[] = $v; + } + + $v = ''; + continue; + } + + if ($isQuoted && $value[$i] === '\\') { + $isEscaped = true; + $v .= $value[$i]; + + continue; + } + if ($value[$i] === '"') { + $isQuoted = !$isQuoted; + $v .= $value[$i]; + + continue; + } + + $v .= $value[$i]; + } + + $v = \trim($v); + if ($v !== '') { + $result[] = $v; + } + } + + return $result; + } +} diff --git a/vendor/guzzlehttp/psr7/src/HttpFactory.php b/vendor/guzzlehttp/psr7/src/HttpFactory.php new file mode 100644 index 000000000..3ef15103a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/HttpFactory.php @@ -0,0 +1,94 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseFactoryInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestFactoryInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; +use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UriFactoryInterface; +use Psr\Http\Message\UriInterface; + +/** + * Implements all of the PSR-17 interfaces. + * + * Note: in consuming code it is recommended to require the implemented interfaces + * and inject the instance of this class multiple times. + */ +final class HttpFactory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface +{ + public function createUploadedFile( + StreamInterface $stream, + ?int $size = null, + int $error = \UPLOAD_ERR_OK, + ?string $clientFilename = null, + ?string $clientMediaType = null + ): UploadedFileInterface { + if ($size === null) { + $size = $stream->getSize(); + } + + return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType); + } + + public function createStream(string $content = ''): StreamInterface + { + return Utils::streamFor($content); + } + + public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface + { + try { + $resource = Utils::tryFopen($file, $mode); + } catch (\RuntimeException $e) { + if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) { + throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e); + } + + throw $e; + } + + return Utils::streamFor($resource); + } + + public function createStreamFromResource($resource): StreamInterface + { + return Utils::streamFor($resource); + } + + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface + { + if (empty($method)) { + if (!empty($serverParams['REQUEST_METHOD'])) { + $method = $serverParams['REQUEST_METHOD']; + } else { + throw new \InvalidArgumentException('Cannot determine HTTP method'); + } + } + + return new ServerRequest($method, $uri, [], null, '1.1', $serverParams); + } + + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { + return new Response($code, [], null, '1.1', $reasonPhrase); + } + + public function createRequest(string $method, $uri): RequestInterface + { + return new Request($method, $uri); + } + + public function createUri(string $uri = ''): UriInterface + { + return new Uri($uri); + } +} diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php new file mode 100644 index 000000000..e674c9ab6 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/InflateStream.php @@ -0,0 +1,37 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content. + * + * This stream decorator converts the provided stream to a PHP stream resource, + * then appends the zlib.inflate filter. The stream is then converted back + * to a Guzzle stream resource to be used as a Guzzle stream. + * + * @see https://datatracker.ietf.org/doc/html/rfc1950 + * @see https://datatracker.ietf.org/doc/html/rfc1952 + * @see https://www.php.net/manual/en/filters.compression.php + */ +final class InflateStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var StreamInterface */ + private $stream; + + public function __construct(StreamInterface $stream) + { + $resource = StreamWrapper::getResource($stream); + // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data + // See https://www.zlib.net/manual.html#Advanced definition of inflateInit2 + // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection" + // Default window size is 15. + stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]); + $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); + } +} diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php new file mode 100644 index 000000000..f6c84904e --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Lazily reads or writes to a file that is opened only after an IO operation + * take place on the stream. + */ +final class LazyOpenStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var string */ + private $filename; + + /** @var string */ + private $mode; + + /** + * @var StreamInterface + */ + private $stream; + + /** + * @param string $filename File to lazily open + * @param string $mode fopen mode to use when opening the stream + */ + public function __construct(string $filename, string $mode) + { + $this->filename = $filename; + $this->mode = $mode; + + // unsetting the property forces the first access to go through + // __get(). + unset($this->stream); + } + + /** + * Creates the underlying stream lazily when required. + */ + protected function createStream(): StreamInterface + { + return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode)); + } +} diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php new file mode 100644 index 000000000..fb2232557 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -0,0 +1,157 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Decorator used to return only a subset of a stream. + */ +final class LimitStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var int Offset to start reading from */ + private $offset; + + /** @var int Limit the number of bytes that can be read */ + private $limit; + + /** @var StreamInterface */ + private $stream; + + /** + * @param StreamInterface $stream Stream to wrap + * @param int $limit Total number of bytes to allow to be read + * from the stream. Pass -1 for no limit. + * @param int $offset Position to seek to before reading (only + * works on seekable streams). + */ + public function __construct( + StreamInterface $stream, + int $limit = -1, + int $offset = 0 + ) { + $this->stream = $stream; + $this->setLimit($limit); + $this->setOffset($offset); + } + + public function eof(): bool + { + // Always return true if the underlying stream is EOF + if ($this->stream->eof()) { + return true; + } + + // No limit and the underlying stream is not at EOF + if ($this->limit === -1) { + return false; + } + + return $this->stream->tell() >= $this->offset + $this->limit; + } + + /** + * Returns the size of the limited subset of data + */ + public function getSize(): ?int + { + if (null === ($length = $this->stream->getSize())) { + return null; + } elseif ($this->limit === -1) { + return $length - $this->offset; + } else { + return min($this->limit, $length - $this->offset); + } + } + + /** + * Allow for a bounded seek on the read limited stream + */ + public function seek($offset, $whence = SEEK_SET): void + { + if ($whence !== SEEK_SET || $offset < 0) { + throw new \RuntimeException(sprintf( + 'Cannot seek to offset %s with whence %s', + $offset, + $whence + )); + } + + $offset += $this->offset; + + if ($this->limit !== -1) { + if ($offset > $this->offset + $this->limit) { + $offset = $this->offset + $this->limit; + } + } + + $this->stream->seek($offset); + } + + /** + * Give a relative tell() + */ + public function tell(): int + { + return $this->stream->tell() - $this->offset; + } + + /** + * Set the offset to start limiting from + * + * @param int $offset Offset to seek to and begin byte limiting from + * + * @throws \RuntimeException if the stream cannot be seeked. + */ + public function setOffset(int $offset): void + { + $current = $this->stream->tell(); + + if ($current !== $offset) { + // If the stream cannot seek to the offset position, then read to it + if ($this->stream->isSeekable()) { + $this->stream->seek($offset); + } elseif ($current > $offset) { + throw new \RuntimeException("Could not seek to stream offset $offset"); + } else { + $this->stream->read($offset - $current); + } + } + + $this->offset = $offset; + } + + /** + * Set the limit of bytes that the decorator allows to be read from the + * stream. + * + * @param int $limit Number of bytes to allow to be read from the stream. + * Use -1 for no limit. + */ + public function setLimit(int $limit): void + { + $this->limit = $limit; + } + + public function read($length): string + { + if ($this->limit === -1) { + return $this->stream->read($length); + } + + // Check if the current position is less than the total allowed + // bytes + original offset + $remaining = ($this->offset + $this->limit) - $this->stream->tell(); + if ($remaining > 0) { + // Only return the amount of requested data, ensuring that the byte + // limit is not exceeded + return $this->stream->read(min($remaining, $length)); + } + + return ''; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Message.php b/vendor/guzzlehttp/psr7/src/Message.php new file mode 100644 index 000000000..5561a5130 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Message.php @@ -0,0 +1,246 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +final class Message +{ + /** + * Returns the string representation of an HTTP message. + * + * @param MessageInterface $message Message to convert to a string. + */ + public static function toString(MessageInterface $message): string + { + if ($message instanceof RequestInterface) { + $msg = trim($message->getMethod().' ' + .$message->getRequestTarget()) + .' HTTP/'.$message->getProtocolVersion(); + if (!$message->hasHeader('host')) { + $msg .= "\r\nHost: ".$message->getUri()->getHost(); + } + } elseif ($message instanceof ResponseInterface) { + $msg = 'HTTP/'.$message->getProtocolVersion().' ' + .$message->getStatusCode().' ' + .$message->getReasonPhrase(); + } else { + throw new \InvalidArgumentException('Unknown message type'); + } + + foreach ($message->getHeaders() as $name => $values) { + if (is_string($name) && strtolower($name) === 'set-cookie') { + foreach ($values as $value) { + $msg .= "\r\n{$name}: ".$value; + } + } else { + $msg .= "\r\n{$name}: ".implode(', ', $values); + } + } + + return "{$msg}\r\n\r\n".$message->getBody(); + } + + /** + * Get a short summary of the message body. + * + * Will return `null` if the response is not printable. + * + * @param MessageInterface $message The message to get the body summary + * @param int $truncateAt The maximum allowed size of the summary + */ + public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string + { + $body = $message->getBody(); + + if (!$body->isSeekable() || !$body->isReadable()) { + return null; + } + + $size = $body->getSize(); + + if ($size === 0) { + return null; + } + + $body->rewind(); + $summary = $body->read($truncateAt); + $body->rewind(); + + if ($size > $truncateAt) { + $summary .= ' (truncated...)'; + } + + // Matches any printable character, including unicode characters: + // letters, marks, numbers, punctuation, spacing, and separators. + if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) { + return null; + } + + return $summary; + } + + /** + * Attempts to rewind a message body and throws an exception on failure. + * + * The body of the message will only be rewound if a call to `tell()` + * returns a value other than `0`. + * + * @param MessageInterface $message Message to rewind + * + * @throws \RuntimeException + */ + public static function rewindBody(MessageInterface $message): void + { + $body = $message->getBody(); + + if ($body->tell()) { + $body->rewind(); + } + } + + /** + * Parses an HTTP message into an associative array. + * + * The array contains the "start-line" key containing the start line of + * the message, "headers" key containing an associative array of header + * array values, and a "body" key containing the body of the message. + * + * @param string $message HTTP request or response to parse. + */ + public static function parseMessage(string $message): array + { + if (!$message) { + throw new \InvalidArgumentException('Invalid message'); + } + + $message = ltrim($message, "\r\n"); + + $messageParts = preg_split("/\r?\n\r?\n/", $message, 2); + + if ($messageParts === false || count($messageParts) !== 2) { + throw new \InvalidArgumentException('Invalid message: Missing header delimiter'); + } + + [$rawHeaders, $body] = $messageParts; + $rawHeaders .= "\r\n"; // Put back the delimiter we split previously + $headerParts = preg_split("/\r?\n/", $rawHeaders, 2); + + if ($headerParts === false || count($headerParts) !== 2) { + throw new \InvalidArgumentException('Invalid message: Missing status line'); + } + + [$startLine, $rawHeaders] = $headerParts; + + if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') { + // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0 + $rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders); + } + + /** @var array[] $headerLines */ + $count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER); + + // If these aren't the same, then one line didn't match and there's an invalid header. + if ($count !== substr_count($rawHeaders, "\n")) { + // Folding is deprecated, see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4 + if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) { + throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding'); + } + + throw new \InvalidArgumentException('Invalid header syntax'); + } + + $headers = []; + + foreach ($headerLines as $headerLine) { + $headers[$headerLine[1]][] = $headerLine[2]; + } + + return [ + 'start-line' => $startLine, + 'headers' => $headers, + 'body' => $body, + ]; + } + + /** + * Constructs a URI for an HTTP request message. + * + * @param string $path Path from the start-line + * @param array $headers Array of headers (each value an array). + */ + public static function parseRequestUri(string $path, array $headers): string + { + $hostKey = array_filter(array_keys($headers), function ($k) { + // Numeric array keys are converted to int by PHP. + $k = (string) $k; + + return strtolower($k) === 'host'; + }); + + // If no host is found, then a full URI cannot be constructed. + if (!$hostKey) { + return $path; + } + + $host = $headers[reset($hostKey)][0]; + $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; + + return $scheme.'://'.$host.'/'.ltrim($path, '/'); + } + + /** + * Parses a request message string into a request object. + * + * @param string $message Request message string. + */ + public static function parseRequest(string $message): RequestInterface + { + $data = self::parseMessage($message); + $matches = []; + if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { + throw new \InvalidArgumentException('Invalid request string'); + } + $parts = explode(' ', $data['start-line'], 3); + $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; + + $request = new Request( + $parts[0], + $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1], + $data['headers'], + $data['body'], + $version + ); + + return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); + } + + /** + * Parses a response message string into a response object. + * + * @param string $message Response message string. + */ + public static function parseResponse(string $message): ResponseInterface + { + $data = self::parseMessage($message); + // According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2 + // the space between status-code and reason-phrase is required. But + // browsers accept responses without space and reason as well. + if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) { + throw new \InvalidArgumentException('Invalid response string: '.$data['start-line']); + } + $parts = explode(' ', $data['start-line'], 3); + + return new Response( + (int) $parts[1], + $data['headers'], + $data['body'], + explode('/', $parts[0])[1], + $parts[2] ?? null + ); + } +} diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php new file mode 100644 index 000000000..65dbc4ba0 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -0,0 +1,265 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\StreamInterface; + +/** + * Trait implementing functionality common to requests and responses. + */ +trait MessageTrait +{ + /** @var string[][] Map of all registered headers, as original name => array of values */ + private $headers = []; + + /** @var string[] Map of lowercase header name => original name at registration */ + private $headerNames = []; + + /** @var string */ + private $protocol = '1.1'; + + /** @var StreamInterface|null */ + private $stream; + + public function getProtocolVersion(): string + { + return $this->protocol; + } + + public function withProtocolVersion($version): MessageInterface + { + if ($this->protocol === $version) { + return $this; + } + + $new = clone $this; + $new->protocol = $version; + + return $new; + } + + public function getHeaders(): array + { + return $this->headers; + } + + public function hasHeader($header): bool + { + return isset($this->headerNames[strtolower($header)]); + } + + public function getHeader($header): array + { + $header = strtolower($header); + + if (!isset($this->headerNames[$header])) { + return []; + } + + $header = $this->headerNames[$header]; + + return $this->headers[$header]; + } + + public function getHeaderLine($header): string + { + return implode(', ', $this->getHeader($header)); + } + + public function withHeader($header, $value): MessageInterface + { + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + unset($new->headers[$new->headerNames[$normalized]]); + } + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + + return $new; + } + + public function withAddedHeader($header, $value): MessageInterface + { + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $new->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + } + + return $new; + } + + public function withoutHeader($header): MessageInterface + { + $normalized = strtolower($header); + + if (!isset($this->headerNames[$normalized])) { + return $this; + } + + $header = $this->headerNames[$normalized]; + + $new = clone $this; + unset($new->headers[$header], $new->headerNames[$normalized]); + + return $new; + } + + public function getBody(): StreamInterface + { + if (!$this->stream) { + $this->stream = Utils::streamFor(''); + } + + return $this->stream; + } + + public function withBody(StreamInterface $body): MessageInterface + { + if ($body === $this->stream) { + return $this; + } + + $new = clone $this; + $new->stream = $body; + + return $new; + } + + /** + * @param (string|string[])[] $headers + */ + private function setHeaders(array $headers): void + { + $this->headerNames = $this->headers = []; + foreach ($headers as $header => $value) { + // Numeric array keys are converted to int by PHP. + $header = (string) $header; + + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); + $normalized = strtolower($header); + if (isset($this->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $this->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $this->headerNames[$normalized] = $header; + $this->headers[$header] = $value; + } + } + } + + /** + * @param mixed $value + * + * @return string[] + */ + private function normalizeHeaderValue($value): array + { + if (!is_array($value)) { + return $this->trimAndValidateHeaderValues([$value]); + } + + if (count($value) === 0) { + throw new \InvalidArgumentException('Header value can not be an empty array.'); + } + + return $this->trimAndValidateHeaderValues($value); + } + + /** + * Trims whitespace from the header values. + * + * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. + * + * header-field = field-name ":" OWS field-value OWS + * OWS = *( SP / HTAB ) + * + * @param mixed[] $values Header values + * + * @return string[] Trimmed header values + * + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4 + */ + private function trimAndValidateHeaderValues(array $values): array + { + return array_map(function ($value) { + if (!is_scalar($value) && null !== $value) { + throw new \InvalidArgumentException(sprintf( + 'Header value must be scalar or null but %s provided.', + is_object($value) ? get_class($value) : gettype($value) + )); + } + + $trimmed = trim((string) $value, " \t"); + $this->assertValue($trimmed); + + return $trimmed; + }, array_values($values)); + } + + /** + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 + * + * @param mixed $header + */ + private function assertHeader($header): void + { + if (!is_string($header)) { + throw new \InvalidArgumentException(sprintf( + 'Header name must be a string but %s provided.', + is_object($header) ? get_class($header) : gettype($header) + )); + } + + if (!preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { + throw new \InvalidArgumentException( + sprintf('"%s" is not valid header name.', $header) + ); + } + } + + /** + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 + * + * field-value = *( field-content / obs-fold ) + * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] + * field-vchar = VCHAR / obs-text + * VCHAR = %x21-7E + * obs-text = %x80-FF + * obs-fold = CRLF 1*( SP / HTAB ) + */ + private function assertValue(string $value): void + { + // The regular expression intentionally does not support the obs-fold production, because as + // per RFC 7230#3.2.4: + // + // A sender MUST NOT generate a message that includes + // line folding (i.e., that has any field-value that contains a match to + // the obs-fold rule) unless the message is intended for packaging + // within the message/http media type. + // + // Clients must not send a request with line folding and a server sending folded headers is + // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting + // folding is not likely to break any legitimate use case. + if (!preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) { + throw new \InvalidArgumentException( + sprintf('"%s" is not valid header value.', $value) + ); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/MimeType.php b/vendor/guzzlehttp/psr7/src/MimeType.php new file mode 100644 index 000000000..b131bdbe7 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/MimeType.php @@ -0,0 +1,1259 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +final class MimeType +{ + private const MIME_TYPES = [ + '1km' => 'application/vnd.1000minds.decision-model+xml', + '3dml' => 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gp', + '3gpp' => 'video/3gpp', + '3mf' => 'model/3mf', + '7z' => 'application/x-7z-compressed', + '7zip' => 'application/x-7z-compressed', + '123' => 'application/vnd.lotus-1-2-3', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/aac', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/vnd.nokia.n-gage.ac+xml', + 'ac3' => 'audio/ac3', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'adts' => 'audio/aac', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'age' => 'application/vnd.age', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/pdf', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'aml' => 'application/automationml-aml+xml', + 'amlx' => 'application/automationml-amlx+zip', + 'amr' => 'audio/amr', + 'apk' => 'application/vnd.android.package-archive', + 'apng' => 'image/apng', + 'appcache' => 'text/cache-manifest', + 'appinstaller' => 'application/appinstaller', + 'application' => 'application/x-ms-application', + 'appx' => 'application/appx', + 'appxbundle' => 'application/appxbundle', + 'apr' => 'application/vnd.lotus-approach', + 'arc' => 'application/x-freearc', + 'arj' => 'application/x-arj', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomdeleted' => 'application/atomdeleted+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/x-au', + 'avci' => 'image/avci', + 'avcs' => 'image/avcs', + 'avi' => 'video/x-msvideo', + 'avif' => 'image/avif', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azv' => 'image/vnd.airzip.accelerator.azv', + 'azw' => 'application/vnd.amazon.ebook', + 'b16' => 'image/vnd.pco.b16', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bdoc' => 'application/x-bdoc', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmml' => 'application/vnd.balsamiq.bmml+xml', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'bpmn' => 'application/octet-stream', + 'bsp' => 'model/vnd.valve.source.compiled-map', + 'btf' => 'image/prs.btif', + 'btif' => 'image/prs.btif', + 'buffer' => 'application/octet-stream', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cco' => 'application/x-cocoa', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdfx' => 'application/cdfx+xml', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdr' => 'application/cdr', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cjs' => 'application/node', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/octet-stream', + 'cld' => 'model/vnd.cld', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'coffee' => 'text/coffeescript', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpl' => 'application/cpl+xml', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'crx' => 'application/x-chrome-extension', + 'cryptonote' => 'application/vnd.rig.cryptonote', + 'csh' => 'application/x-csh', + 'csl' => 'application/vnd.citationstyles.style+xml', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'csr' => 'application/octet-stream', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cwl' => 'application/cwl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbf' => 'application/vnd.dbf', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'ddf' => 'application/vnd.syncml.dmddf+xml', + 'dds' => 'image/vnd.ms-dds', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dib' => 'image/bmp', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'disposition-notification' => 'message/disposition-notification', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/octet-stream', + 'dmg' => 'application/x-apple-diskimage', + 'dmn' => 'application/octet-stream', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dpx' => 'image/dpx', + 'dra' => 'audio/vnd.dra', + 'drle' => 'image/dicom-rle', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwd' => 'application/atsc-dwd+xml', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ear' => 'application/java-archive', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'image/emf', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emotionml' => 'application/emotionml+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/octet-stream', + 'exi' => 'application/exi', + 'exp' => 'application/express', + 'exr' => 'image/aces', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/mp4', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fdt' => 'application/fdt+xml', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'fits' => 'image/fits', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'fo' => 'application/vnd.software602.filler.form+xml', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'gdoc' => 'application/vnd.google-apps.document', + 'ged' => 'text/vnd.familysearch.gedcom', + 'geo' => 'application/vnd.dynageo', + 'geojson' => 'application/geo+json', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'glb' => 'model/gltf-binary', + 'gltf' => 'model/gltf+json', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gpg' => 'application/gpg-keys', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gsheet' => 'application/vnd.google-apps.spreadsheet', + 'gslides' => 'application/vnd.google-apps.presentation', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/gzip', + 'gzip' => 'application/gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hbs' => 'text/x-handlebars-template', + 'hdd' => 'application/x-virtualbox-hdd', + 'hdf' => 'application/x-hdf', + 'heic' => 'image/heic', + 'heics' => 'image/heic-sequence', + 'heif' => 'image/heif', + 'heifs' => 'image/heif-sequence', + 'hej2' => 'image/hej2k', + 'held' => 'application/atsc-held+xml', + 'hh' => 'text/x-c', + 'hjson' => 'application/hjson', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'hsj2' => 'image/hsj2', + 'htc' => 'text/x-component', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'img' => 'application/octet-stream', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ini' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'its' => 'application/its+xml', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jade' => 'text/jade', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'jardiff' => 'application/x-java-archive-diff', + 'java' => 'text/x-java-source', + 'jhc' => 'image/jphc', + 'jisp' => 'application/vnd.jisp', + 'jls' => 'image/jls', + 'jlt' => 'application/vnd.hp-jlyt', + 'jng' => 'image/x-jng', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jp2' => 'image/jp2', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpf' => 'image/jpx', + 'jpg' => 'image/jpeg', + 'jpg2' => 'image/jp2', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jph' => 'image/jph', + 'jpm' => 'video/jpm', + 'jpx' => 'image/jpx', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'json5' => 'application/json5', + 'jsonld' => 'application/ld+json', + 'jsonml' => 'application/jsonml+json', + 'jsx' => 'text/jsx', + 'jt' => 'model/jt', + 'jxr' => 'image/jxr', + 'jxra' => 'image/jxra', + 'jxrs' => 'image/jxrs', + 'jxs' => 'image/jxs', + 'jxsc' => 'image/jxsc', + 'jxsi' => 'image/jxsi', + 'jxss' => 'image/jxss', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kdb' => 'application/octet-stream', + 'kdbx' => 'application/x-keepass2', + 'key' => 'application/x-iwork-keynote-sffkey', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktx2' => 'image/ktx2', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'less' => 'text/less', + 'lgr' => 'application/lgr+xml', + 'lha' => 'application/octet-stream', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'litcoffee' => 'text/coffeescript', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lua' => 'text/x-lua', + 'luac' => 'application/x-lua-bytecode', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/octet-stream', + 'm1v' => 'video/mpeg', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'text/plain', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/x-m4a', + 'm4p' => 'application/mp4', + 'm4s' => 'video/iso.segment', + 'm4u' => 'application/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm21' => 'application/mp21', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'maei' => 'application/mmt-aei+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'manifest' => 'text/cache-manifest', + 'map' => 'application/json', + 'mar' => 'application/octet-stream', + 'markdown' => 'text/markdown', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'md' => 'text/markdown', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'mdx' => 'text/mdx', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mjs' => 'text/javascript', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mkd' => 'text/x-markdown', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mml' => 'text/mathml', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mp21' => 'application/mp21', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpd' => 'application/dash+xml', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpf' => 'application/media-policy-dataset+xml', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msg' => 'application/vnd.ms-outlook', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msix' => 'application/msix', + 'msixbundle' => 'application/msixbundle', + 'msl' => 'application/vnd.mobius.msl', + 'msm' => 'application/octet-stream', + 'msp' => 'application/octet-stream', + 'msty' => 'application/vnd.muvee.style', + 'mtl' => 'model/mtl', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musd' => 'application/mmt-usd+xml', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mvt' => 'application/vnd.mapbox-vector-tile', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxmf' => 'audio/mobile-xmf', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nq' => 'application/n-quads', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'nt' => 'application/n-triples', + 'ntf' => 'application/vnd.nitf', + 'numbers' => 'application/x-iwork-numbers-sffnumbers', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obgx' => 'application/vnd.openblox.game+xml', + 'obj' => 'model/obj', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogex' => 'model/vnd.opengex', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'opus' => 'audio/ogg', + 'org' => 'text/x-org', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'osm' => 'application/vnd.openstreetmap.data+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'font/otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'ova' => 'application/x-virtualbox-ova', + 'ovf' => 'application/x-virtualbox-ovf', + 'owl' => 'application/rdf+xml', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p7a' => 'application/x-pkcs7-signature', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'p10' => 'application/x-pkcs10', + 'p12' => 'application/x-pkcs12', + 'pac' => 'application/x-ns-proxy-autoconfig', + 'pages' => 'application/x-iwork-pages-sffpages', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/x-pilot', + 'pde' => 'text/x-processing', + 'pdf' => 'application/pdf', + 'pem' => 'application/x-x509-user-cert', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp', + 'phar' => 'application/octet-stream', + 'php' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'phtml' => 'application/x-httpd-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'pkpass' => 'application/vnd.apple.pkpass', + 'pl' => 'application/x-perl', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pm' => 'application/x-perl', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppa' => 'application/vnd.ms-powerpoint', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'model/prc', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'provx' => 'application/provenance+xml', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'application/x-photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'pti' => 'image/prs.pti', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyo' => 'model/vnd.pytha.pyox', + 'pyox' => 'model/vnd.pytha.pyox', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'raml' => 'application/raml+yaml', + 'rapd' => 'application/route-apd+xml', + 'rar' => 'application/x-rar', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'relo' => 'application/p2p-overlay+xml', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'audio/x-pn-realaudio', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'rng' => 'application/xml', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsa' => 'application/x-pkcs7', + 'rsat' => 'application/atsc-rsat+xml', + 'rsd' => 'application/rsd+xml', + 'rsheet' => 'application/urc-ressheet+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'text/rtf', + 'rtx' => 'text/richtext', + 'run' => 'application/x-makeself', + 'rusd' => 'application/route-usd+xml', + 'rv' => 'video/vnd.rn-realvideo', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sass' => 'text/x-sass', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scss' => 'text/x-scss', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'sea' => 'application/octet-stream', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'senmlx' => 'application/senml+xml', + 'sensmlx' => 'application/sensml+xml', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shex' => 'text/shex', + 'shf' => 'application/shf+xml', + 'shtml' => 'text/html', + 'sid' => 'image/x-mrsid-image', + 'sieve' => 'application/sieve', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'siv' => 'application/sieve', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slim' => 'text/slim', + 'slm' => 'text/slim', + 'sls' => 'application/route-s-tsid+xml', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spdx' => 'text/spdx', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'sst' => 'application/octet-stream', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'step' => 'application/STEP', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'model/stl', + 'stp' => 'application/STEP', + 'stpx' => 'model/step+xml', + 'stpxz' => 'model/step-xml+zip', + 'stpz' => 'model/step+zip', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'styl' => 'text/stylus', + 'stylus' => 'text/stylus', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'swidtag' => 'application/swid+xml', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 't38' => 'image/t38', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tap' => 'image/vnd.tencent.tap', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'td' => 'application/urc-targetdesc+xml', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tfx' => 'image/tiff-fx', + 'tga' => 'image/x-tga', + 'tgz' => 'application/x-tar', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tk' => 'application/x-tcl', + 'tmo' => 'application/vnd.tmobile-livetv', + 'toml' => 'application/toml', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trig' => 'application/trig', + 'trm' => 'application/x-msterminal', + 'ts' => 'video/mp2t', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'font/collection', + 'ttf' => 'font/ttf', + 'ttl' => 'text/turtle', + 'ttml' => 'application/ttml+xml', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u3d' => 'model/u3d', + 'u8dsn' => 'message/global-delivery-status', + 'u8hdr' => 'message/global-headers', + 'u8mdn' => 'message/global-disposition-notification', + 'u8msg' => 'message/global', + 'u32' => 'application/x-authorware-bin', + 'ubj' => 'application/ubjson', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uo' => 'application/vnd.uoml+xml', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'usda' => 'model/vnd.usda', + 'usdz' => 'model/vnd.usdz+zip', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vbox' => 'application/x-virtualbox-vbox', + 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vdi' => 'application/x-virtualbox-vdi', + 'vds' => 'model/vnd.sap.vds', + 'vhd' => 'application/x-virtualbox-vhd', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vlc' => 'application/videolan', + 'vmdk' => 'application/x-virtualbox-vmdk', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtf' => 'image/vnd.valve.source.texture', + 'vtt' => 'text/vtt', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wadl' => 'application/vnd.sun.wadl+xml', + 'war' => 'application/java-archive', + 'wasm' => 'application/wasm', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webapp' => 'application/x-web-app-manifest+json', + 'webm' => 'video/webm', + 'webmanifest' => 'application/manifest+json', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgsl' => 'text/wgsl', + 'wgt' => 'application/widget', + 'wif' => 'application/watcherinfo+xml', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'image/wmf', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'font/woff', + 'woff2' => 'font/woff2', + 'word' => 'application/msword', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsc' => 'message/vnd.wfa.wsc', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+fastinfoset', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d-vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'x32' => 'application/x-authorware-bin', + 'x_b' => 'model/vnd.parasolid.transmit.binary', + 'x_t' => 'model/vnd.parasolid.transmit.text', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xav' => 'application/xcap-att+xml', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xca' => 'application/xcap-caps+xml', + 'xcs' => 'application/calendar+xml', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xel' => 'application/xcap-el+xml', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtm' => 'application/vnd.pwg-xhtml-print+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xl' => 'application/excel', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xns' => 'application/xcap-ns+xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsd' => 'application/xml', + 'xsf' => 'application/prs.xsf+xml', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yaml' => 'text/yaml', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'yml' => 'text/yaml', + 'ymp' => 'text/x-suse-ymp', + 'z' => 'application/x-compress', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + 'zsh' => 'text/x-scriptzsh', + ]; + + /** + * Determines the mimetype of a file by looking at its extension. + * + * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json + */ + public static function fromFilename(string $filename): ?string + { + return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION)); + } + + /** + * Maps a file extensions to a mimetype. + * + * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json + */ + public static function fromExtension(string $extension): ?string + { + return self::MIME_TYPES[strtolower($extension)] ?? null; + } +} diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php new file mode 100644 index 000000000..43d718f65 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/MultipartStream.php @@ -0,0 +1,165 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream that when read returns bytes for a streaming multipart or + * multipart/form-data stream. + */ +final class MultipartStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var string */ + private $boundary; + + /** @var StreamInterface */ + private $stream; + + /** + * @param array $elements Array of associative arrays, each containing a + * required "name" key mapping to the form field, + * name, a required "contents" key mapping to a + * StreamInterface/resource/string, an optional + * "headers" associative array of custom headers, + * and an optional "filename" key mapping to a + * string to send as the filename in the part. + * @param string $boundary You can optionally provide a specific boundary + * + * @throws \InvalidArgumentException + */ + public function __construct(array $elements = [], ?string $boundary = null) + { + $this->boundary = $boundary ?: bin2hex(random_bytes(20)); + $this->stream = $this->createStream($elements); + } + + public function getBoundary(): string + { + return $this->boundary; + } + + public function isWritable(): bool + { + return false; + } + + /** + * Get the headers needed before transferring the content of a POST file + * + * @param string[] $headers + */ + private function getHeaders(array $headers): string + { + $str = ''; + foreach ($headers as $key => $value) { + $str .= "{$key}: {$value}\r\n"; + } + + return "--{$this->boundary}\r\n".trim($str)."\r\n\r\n"; + } + + /** + * Create the aggregate stream that will be used to upload the POST data + */ + protected function createStream(array $elements = []): StreamInterface + { + $stream = new AppendStream(); + + foreach ($elements as $element) { + if (!is_array($element)) { + throw new \UnexpectedValueException('An array is expected'); + } + $this->addElement($stream, $element); + } + + // Add the trailing boundary with CRLF + $stream->addStream(Utils::streamFor("--{$this->boundary}--\r\n")); + + return $stream; + } + + private function addElement(AppendStream $stream, array $element): void + { + foreach (['contents', 'name'] as $key) { + if (!array_key_exists($key, $element)) { + throw new \InvalidArgumentException("A '{$key}' key is required"); + } + } + + $element['contents'] = Utils::streamFor($element['contents']); + + if (empty($element['filename'])) { + $uri = $element['contents']->getMetadata('uri'); + if ($uri && \is_string($uri) && \substr($uri, 0, 6) !== 'php://' && \substr($uri, 0, 7) !== 'data://') { + $element['filename'] = $uri; + } + } + + [$body, $headers] = $this->createElement( + $element['name'], + $element['contents'], + $element['filename'] ?? null, + $element['headers'] ?? [] + ); + + $stream->addStream(Utils::streamFor($this->getHeaders($headers))); + $stream->addStream($body); + $stream->addStream(Utils::streamFor("\r\n")); + } + + /** + * @param string[] $headers + * + * @return array{0: StreamInterface, 1: string[]} + */ + private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array + { + // Set a default content-disposition header if one was no provided + $disposition = self::getHeader($headers, 'content-disposition'); + if (!$disposition) { + $headers['Content-Disposition'] = ($filename === '0' || $filename) + ? sprintf( + 'form-data; name="%s"; filename="%s"', + $name, + basename($filename) + ) + : "form-data; name=\"{$name}\""; + } + + // Set a default content-length header if one was no provided + $length = self::getHeader($headers, 'content-length'); + if (!$length) { + if ($length = $stream->getSize()) { + $headers['Content-Length'] = (string) $length; + } + } + + // Set a default Content-Type if one was not supplied + $type = self::getHeader($headers, 'content-type'); + if (!$type && ($filename === '0' || $filename)) { + $headers['Content-Type'] = MimeType::fromFilename($filename) ?? 'application/octet-stream'; + } + + return [$stream, $headers]; + } + + /** + * @param string[] $headers + */ + private static function getHeader(array $headers, string $key): ?string + { + $lowercaseHeader = strtolower($key); + foreach ($headers as $k => $v) { + if (strtolower((string) $k) === $lowercaseHeader) { + return $v; + } + } + + return null; + } +} diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php new file mode 100644 index 000000000..161a224f0 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/NoSeekStream.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator that prevents a stream from being seeked. + */ +final class NoSeekStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var StreamInterface */ + private $stream; + + public function seek($offset, $whence = SEEK_SET): void + { + throw new \RuntimeException('Cannot seek a NoSeekStream'); + } + + public function isSeekable(): bool + { + return false; + } +} diff --git a/vendor/guzzlehttp/psr7/src/PumpStream.php b/vendor/guzzlehttp/psr7/src/PumpStream.php new file mode 100644 index 000000000..e2040709f --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/PumpStream.php @@ -0,0 +1,179 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Provides a read only stream that pumps data from a PHP callable. + * + * When invoking the provided callable, the PumpStream will pass the amount of + * data requested to read to the callable. The callable can choose to ignore + * this value and return fewer or more bytes than requested. Any extra data + * returned by the provided callable is buffered internally until drained using + * the read() function of the PumpStream. The provided callable MUST return + * false when there is no more data to read. + */ +final class PumpStream implements StreamInterface +{ + /** @var callable(int): (string|false|null)|null */ + private $source; + + /** @var int|null */ + private $size; + + /** @var int */ + private $tellPos = 0; + + /** @var array */ + private $metadata; + + /** @var BufferStream */ + private $buffer; + + /** + * @param callable(int): (string|false|null) $source Source of the stream data. The callable MAY + * accept an integer argument used to control the + * amount of data to return. The callable MUST + * return a string when called, or false|null on error + * or EOF. + * @param array{size?: int, metadata?: array} $options Stream options: + * - metadata: Hash of metadata to use with stream. + * - size: Size of the stream, if known. + */ + public function __construct(callable $source, array $options = []) + { + $this->source = $source; + $this->size = $options['size'] ?? null; + $this->metadata = $options['metadata'] ?? []; + $this->buffer = new BufferStream(); + } + + public function __toString(): string + { + try { + return Utils::copyToString($this); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function close(): void + { + $this->detach(); + } + + public function detach() + { + $this->tellPos = 0; + $this->source = null; + + return null; + } + + public function getSize(): ?int + { + return $this->size; + } + + public function tell(): int + { + return $this->tellPos; + } + + public function eof(): bool + { + return $this->source === null; + } + + public function isSeekable(): bool + { + return false; + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + throw new \RuntimeException('Cannot seek a PumpStream'); + } + + public function isWritable(): bool + { + return false; + } + + public function write($string): int + { + throw new \RuntimeException('Cannot write to a PumpStream'); + } + + public function isReadable(): bool + { + return true; + } + + public function read($length): string + { + $data = $this->buffer->read($length); + $readLen = strlen($data); + $this->tellPos += $readLen; + $remaining = $length - $readLen; + + if ($remaining) { + $this->pump($remaining); + $data .= $this->buffer->read($remaining); + $this->tellPos += strlen($data) - $readLen; + } + + return $data; + } + + public function getContents(): string + { + $result = ''; + while (!$this->eof()) { + $result .= $this->read(1000000); + } + + return $result; + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + if (!$key) { + return $this->metadata; + } + + return $this->metadata[$key] ?? null; + } + + private function pump(int $length): void + { + if ($this->source !== null) { + do { + $data = ($this->source)($length); + if ($data === false || $data === null) { + $this->source = null; + + return; + } + $this->buffer->write($data); + $length -= strlen($data); + } while ($length > 0); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/Query.php b/vendor/guzzlehttp/psr7/src/Query.php new file mode 100644 index 000000000..ccf867a0b --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Query.php @@ -0,0 +1,118 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +final class Query +{ + /** + * Parse a query string into an associative array. + * + * If multiple values are found for the same key, the value of that key + * value pair will become an array. This function does not parse nested + * PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2` + * will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`. + * + * @param string $str Query string to parse + * @param int|bool $urlEncoding How the query string is encoded + */ + public static function parse(string $str, $urlEncoding = true): array + { + $result = []; + + if ($str === '') { + return $result; + } + + if ($urlEncoding === true) { + $decoder = function ($value) { + return rawurldecode(str_replace('+', ' ', (string) $value)); + }; + } elseif ($urlEncoding === PHP_QUERY_RFC3986) { + $decoder = 'rawurldecode'; + } elseif ($urlEncoding === PHP_QUERY_RFC1738) { + $decoder = 'urldecode'; + } else { + $decoder = function ($str) { + return $str; + }; + } + + foreach (explode('&', $str) as $kvp) { + $parts = explode('=', $kvp, 2); + $key = $decoder($parts[0]); + $value = isset($parts[1]) ? $decoder($parts[1]) : null; + if (!array_key_exists($key, $result)) { + $result[$key] = $value; + } else { + if (!is_array($result[$key])) { + $result[$key] = [$result[$key]]; + } + $result[$key][] = $value; + } + } + + return $result; + } + + /** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of `parse()` to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like `http_build_query()` would). + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, + * PHP_QUERY_RFC3986 to encode using + * RFC3986, or PHP_QUERY_RFC1738 to + * encode using RFC1738. + * @param bool $treatBoolsAsInts Set to true to encode as 0/1, and + * false as false/true. + */ + public static function build(array $params, $encoding = PHP_QUERY_RFC3986, bool $treatBoolsAsInts = true): string + { + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function (string $str): string { + return $str; + }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $castBool = $treatBoolsAsInts ? static function ($v) { return (int) $v; } : static function ($v) { return $v ? 'true' : 'false'; }; + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder((string) $k); + if (!is_array($v)) { + $qs .= $k; + $v = is_bool($v) ? $castBool($v) : $v; + if ($v !== null) { + $qs .= '='.$encoder((string) $v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + $vv = is_bool($vv) ? $castBool($vv) : $vv; + if ($vv !== null) { + $qs .= '='.$encoder((string) $vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php new file mode 100644 index 000000000..faafe1ad8 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Request.php @@ -0,0 +1,159 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use InvalidArgumentException; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + +/** + * PSR-7 request implementation. + */ +class Request implements RequestInterface +{ + use MessageTrait; + + /** @var string */ + private $method; + + /** @var string|null */ + private $requestTarget; + + /** @var UriInterface */ + private $uri; + + /** + * @param string $method HTTP method + * @param string|UriInterface $uri URI + * @param (string|string[])[] $headers Request headers + * @param string|resource|StreamInterface|null $body Request body + * @param string $version Protocol version + */ + public function __construct( + string $method, + $uri, + array $headers = [], + $body = null, + string $version = '1.1' + ) { + $this->assertMethod($method); + if (!($uri instanceof UriInterface)) { + $uri = new Uri($uri); + } + + $this->method = strtoupper($method); + $this->uri = $uri; + $this->setHeaders($headers); + $this->protocol = $version; + + if (!isset($this->headerNames['host'])) { + $this->updateHostFromUri(); + } + + if ($body !== '' && $body !== null) { + $this->stream = Utils::streamFor($body); + } + } + + public function getRequestTarget(): string + { + if ($this->requestTarget !== null) { + return $this->requestTarget; + } + + $target = $this->uri->getPath(); + if ($target === '') { + $target = '/'; + } + if ($this->uri->getQuery() != '') { + $target .= '?'.$this->uri->getQuery(); + } + + return $target; + } + + public function withRequestTarget($requestTarget): RequestInterface + { + if (preg_match('#\s#', $requestTarget)) { + throw new InvalidArgumentException( + 'Invalid request target provided; cannot contain whitespace' + ); + } + + $new = clone $this; + $new->requestTarget = $requestTarget; + + return $new; + } + + public function getMethod(): string + { + return $this->method; + } + + public function withMethod($method): RequestInterface + { + $this->assertMethod($method); + $new = clone $this; + $new->method = strtoupper($method); + + return $new; + } + + public function getUri(): UriInterface + { + return $this->uri; + } + + public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface + { + if ($uri === $this->uri) { + return $this; + } + + $new = clone $this; + $new->uri = $uri; + + if (!$preserveHost || !isset($this->headerNames['host'])) { + $new->updateHostFromUri(); + } + + return $new; + } + + private function updateHostFromUri(): void + { + $host = $this->uri->getHost(); + + if ($host == '') { + return; + } + + if (($port = $this->uri->getPort()) !== null) { + $host .= ':'.$port; + } + + if (isset($this->headerNames['host'])) { + $header = $this->headerNames['host']; + } else { + $header = 'Host'; + $this->headerNames['host'] = 'Host'; + } + // Ensure Host is the first header. + // See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4 + $this->headers = [$header => [$host]] + $this->headers; + } + + /** + * @param mixed $method + */ + private function assertMethod($method): void + { + if (!is_string($method) || $method === '') { + throw new InvalidArgumentException('Method must be a non-empty string.'); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php new file mode 100644 index 000000000..34e612fda --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Response.php @@ -0,0 +1,161 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +/** + * PSR-7 response implementation. + */ +class Response implements ResponseInterface +{ + use MessageTrait; + + /** Map of standard HTTP status code/reason phrases */ + private const PHRASES = [ + 100 => 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-status', + 208 => 'Already Reported', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 306 => 'Switch Proxy', + 307 => 'Temporary Redirect', + 308 => 'Permanent Redirect', + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Time-out', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Large', + 415 => 'Unsupported Media Type', + 416 => 'Requested range not satisfiable', + 417 => 'Expectation Failed', + 418 => 'I\'m a teapot', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 425 => 'Unordered Collection', + 426 => 'Upgrade Required', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + 431 => 'Request Header Fields Too Large', + 451 => 'Unavailable For Legal Reasons', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Time-out', + 505 => 'HTTP Version not supported', + 506 => 'Variant Also Negotiates', + 507 => 'Insufficient Storage', + 508 => 'Loop Detected', + 510 => 'Not Extended', + 511 => 'Network Authentication Required', + ]; + + /** @var string */ + private $reasonPhrase; + + /** @var int */ + private $statusCode; + + /** + * @param int $status Status code + * @param (string|string[])[] $headers Response headers + * @param string|resource|StreamInterface|null $body Response body + * @param string $version Protocol version + * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) + */ + public function __construct( + int $status = 200, + array $headers = [], + $body = null, + string $version = '1.1', + ?string $reason = null + ) { + $this->assertStatusCodeRange($status); + + $this->statusCode = $status; + + if ($body !== '' && $body !== null) { + $this->stream = Utils::streamFor($body); + } + + $this->setHeaders($headers); + if ($reason == '' && isset(self::PHRASES[$this->statusCode])) { + $this->reasonPhrase = self::PHRASES[$this->statusCode]; + } else { + $this->reasonPhrase = (string) $reason; + } + + $this->protocol = $version; + } + + public function getStatusCode(): int + { + return $this->statusCode; + } + + public function getReasonPhrase(): string + { + return $this->reasonPhrase; + } + + public function withStatus($code, $reasonPhrase = ''): ResponseInterface + { + $this->assertStatusCodeIsInteger($code); + $code = (int) $code; + $this->assertStatusCodeRange($code); + + $new = clone $this; + $new->statusCode = $code; + if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) { + $reasonPhrase = self::PHRASES[$new->statusCode]; + } + $new->reasonPhrase = (string) $reasonPhrase; + + return $new; + } + + /** + * @param mixed $statusCode + */ + private function assertStatusCodeIsInteger($statusCode): void + { + if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) { + throw new \InvalidArgumentException('Status code must be an integer value.'); + } + } + + private function assertStatusCodeRange(int $statusCode): void + { + if ($statusCode < 100 || $statusCode >= 600) { + throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.'); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/Rfc7230.php b/vendor/guzzlehttp/psr7/src/Rfc7230.php new file mode 100644 index 000000000..8219dba4d --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Rfc7230.php @@ -0,0 +1,23 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +/** + * @internal + */ +final class Rfc7230 +{ + /** + * Header related regular expressions (based on amphp/http package) + * + * Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons. + * + * @see https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15 + * + * @license https://github.com/amphp/http/blob/v1.0.1/LICENSE + */ + public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m"; + public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)"; +} diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php new file mode 100644 index 000000000..3cc953453 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -0,0 +1,340 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use InvalidArgumentException; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; +use Psr\Http\Message\UriInterface; + +/** + * Server-side HTTP request + * + * Extends the Request definition to add methods for accessing incoming data, + * specifically server parameters, cookies, matched path parameters, query + * string arguments, body parameters, and upload file information. + * + * "Attributes" are discovered via decomposing the request (and usually + * specifically the URI path), and typically will be injected by the application. + * + * Requests are considered immutable; all methods that might change state are + * implemented such that they retain the internal state of the current + * message and return a new instance that contains the changed state. + */ +class ServerRequest extends Request implements ServerRequestInterface +{ + /** + * @var array + */ + private $attributes = []; + + /** + * @var array + */ + private $cookieParams = []; + + /** + * @var array|object|null + */ + private $parsedBody; + + /** + * @var array + */ + private $queryParams = []; + + /** + * @var array + */ + private $serverParams; + + /** + * @var array + */ + private $uploadedFiles = []; + + /** + * @param string $method HTTP method + * @param string|UriInterface $uri URI + * @param (string|string[])[] $headers Request headers + * @param string|resource|StreamInterface|null $body Request body + * @param string $version Protocol version + * @param array $serverParams Typically the $_SERVER superglobal + */ + public function __construct( + string $method, + $uri, + array $headers = [], + $body = null, + string $version = '1.1', + array $serverParams = [] + ) { + $this->serverParams = $serverParams; + + parent::__construct($method, $uri, $headers, $body, $version); + } + + /** + * Return an UploadedFile instance array. + * + * @param array $files An array which respect $_FILES structure + * + * @throws InvalidArgumentException for unrecognized values + */ + public static function normalizeFiles(array $files): array + { + $normalized = []; + + foreach ($files as $key => $value) { + if ($value instanceof UploadedFileInterface) { + $normalized[$key] = $value; + } elseif (is_array($value) && isset($value['tmp_name'])) { + $normalized[$key] = self::createUploadedFileFromSpec($value); + } elseif (is_array($value)) { + $normalized[$key] = self::normalizeFiles($value); + continue; + } else { + throw new InvalidArgumentException('Invalid value in files specification'); + } + } + + return $normalized; + } + + /** + * Create and return an UploadedFile instance from a $_FILES specification. + * + * If the specification represents an array of values, this method will + * delegate to normalizeNestedFileSpec() and return that return value. + * + * @param array $value $_FILES struct + * + * @return UploadedFileInterface|UploadedFileInterface[] + */ + private static function createUploadedFileFromSpec(array $value) + { + if (is_array($value['tmp_name'])) { + return self::normalizeNestedFileSpec($value); + } + + return new UploadedFile( + $value['tmp_name'], + (int) $value['size'], + (int) $value['error'], + $value['name'], + $value['type'] + ); + } + + /** + * Normalize an array of file specifications. + * + * Loops through all nested files and returns a normalized array of + * UploadedFileInterface instances. + * + * @return UploadedFileInterface[] + */ + private static function normalizeNestedFileSpec(array $files = []): array + { + $normalizedFiles = []; + + foreach (array_keys($files['tmp_name']) as $key) { + $spec = [ + 'tmp_name' => $files['tmp_name'][$key], + 'size' => $files['size'][$key] ?? null, + 'error' => $files['error'][$key] ?? null, + 'name' => $files['name'][$key] ?? null, + 'type' => $files['type'][$key] ?? null, + ]; + $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); + } + + return $normalizedFiles; + } + + /** + * Return a ServerRequest populated with superglobals: + * $_GET + * $_POST + * $_COOKIE + * $_FILES + * $_SERVER + */ + public static function fromGlobals(): ServerRequestInterface + { + $method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; + $headers = getallheaders(); + $uri = self::getUriFromGlobals(); + $body = new CachingStream(new LazyOpenStream('php://input', 'r+')); + $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; + + $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); + + return $serverRequest + ->withCookieParams($_COOKIE) + ->withQueryParams($_GET) + ->withParsedBody($_POST) + ->withUploadedFiles(self::normalizeFiles($_FILES)); + } + + private static function extractHostAndPortFromAuthority(string $authority): array + { + $uri = 'http://'.$authority; + $parts = parse_url($uri); + if (false === $parts) { + return [null, null]; + } + + $host = $parts['host'] ?? null; + $port = $parts['port'] ?? null; + + return [$host, $port]; + } + + /** + * Get a Uri populated with values from $_SERVER. + */ + public static function getUriFromGlobals(): UriInterface + { + $uri = new Uri(''); + + $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http'); + + $hasPort = false; + if (isset($_SERVER['HTTP_HOST'])) { + [$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']); + if ($host !== null) { + $uri = $uri->withHost($host); + } + + if ($port !== null) { + $hasPort = true; + $uri = $uri->withPort($port); + } + } elseif (isset($_SERVER['SERVER_NAME'])) { + $uri = $uri->withHost($_SERVER['SERVER_NAME']); + } elseif (isset($_SERVER['SERVER_ADDR'])) { + $uri = $uri->withHost($_SERVER['SERVER_ADDR']); + } + + if (!$hasPort && isset($_SERVER['SERVER_PORT'])) { + $uri = $uri->withPort($_SERVER['SERVER_PORT']); + } + + $hasQuery = false; + if (isset($_SERVER['REQUEST_URI'])) { + $requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2); + $uri = $uri->withPath($requestUriParts[0]); + if (isset($requestUriParts[1])) { + $hasQuery = true; + $uri = $uri->withQuery($requestUriParts[1]); + } + } + + if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) { + $uri = $uri->withQuery($_SERVER['QUERY_STRING']); + } + + return $uri; + } + + public function getServerParams(): array + { + return $this->serverParams; + } + + public function getUploadedFiles(): array + { + return $this->uploadedFiles; + } + + public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface + { + $new = clone $this; + $new->uploadedFiles = $uploadedFiles; + + return $new; + } + + public function getCookieParams(): array + { + return $this->cookieParams; + } + + public function withCookieParams(array $cookies): ServerRequestInterface + { + $new = clone $this; + $new->cookieParams = $cookies; + + return $new; + } + + public function getQueryParams(): array + { + return $this->queryParams; + } + + public function withQueryParams(array $query): ServerRequestInterface + { + $new = clone $this; + $new->queryParams = $query; + + return $new; + } + + /** + * @return array|object|null + */ + public function getParsedBody() + { + return $this->parsedBody; + } + + public function withParsedBody($data): ServerRequestInterface + { + $new = clone $this; + $new->parsedBody = $data; + + return $new; + } + + public function getAttributes(): array + { + return $this->attributes; + } + + /** + * @return mixed + */ + public function getAttribute($attribute, $default = null) + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $default; + } + + return $this->attributes[$attribute]; + } + + public function withAttribute($attribute, $value): ServerRequestInterface + { + $new = clone $this; + $new->attributes[$attribute] = $value; + + return $new; + } + + public function withoutAttribute($attribute): ServerRequestInterface + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $this; + } + + $new = clone $this; + unset($new->attributes[$attribute]); + + return $new; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php new file mode 100644 index 000000000..0aff9b2b7 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Stream.php @@ -0,0 +1,283 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * PHP stream implementation. + */ +class Stream implements StreamInterface +{ + /** + * @see https://www.php.net/manual/en/function.fopen.php + * @see https://www.php.net/manual/en/function.gzopen.php + */ + private const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/'; + private const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/'; + + /** @var resource */ + private $stream; + /** @var int|null */ + private $size; + /** @var bool */ + private $seekable; + /** @var bool */ + private $readable; + /** @var bool */ + private $writable; + /** @var string|null */ + private $uri; + /** @var mixed[] */ + private $customMetadata; + + /** + * This constructor accepts an associative array of options. + * + * - size: (int) If a read stream would otherwise have an indeterminate + * size, but the size is known due to foreknowledge, then you can + * provide that size, in bytes. + * - metadata: (array) Any additional metadata to return when the metadata + * of the stream is accessed. + * + * @param resource $stream Stream resource to wrap. + * @param array{size?: int, metadata?: array} $options Associative array of options. + * + * @throws \InvalidArgumentException if the stream is not a stream resource + */ + public function __construct($stream, array $options = []) + { + if (!is_resource($stream)) { + throw new \InvalidArgumentException('Stream must be a resource'); + } + + if (isset($options['size'])) { + $this->size = $options['size']; + } + + $this->customMetadata = $options['metadata'] ?? []; + $this->stream = $stream; + $meta = stream_get_meta_data($this->stream); + $this->seekable = $meta['seekable']; + $this->readable = (bool) preg_match(self::READABLE_MODES, $meta['mode']); + $this->writable = (bool) preg_match(self::WRITABLE_MODES, $meta['mode']); + $this->uri = $this->getMetadata('uri'); + } + + /** + * Closes the stream when the destructed + */ + public function __destruct() + { + $this->close(); + } + + public function __toString(): string + { + try { + if ($this->isSeekable()) { + $this->seek(0); + } + + return $this->getContents(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function getContents(): string + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); + } + + return Utils::tryGetContents($this->stream); + } + + public function close(): void + { + if (isset($this->stream)) { + if (is_resource($this->stream)) { + fclose($this->stream); + } + $this->detach(); + } + } + + public function detach() + { + if (!isset($this->stream)) { + return null; + } + + $result = $this->stream; + unset($this->stream); + $this->size = $this->uri = null; + $this->readable = $this->writable = $this->seekable = false; + + return $result; + } + + public function getSize(): ?int + { + if ($this->size !== null) { + return $this->size; + } + + if (!isset($this->stream)) { + return null; + } + + // Clear the stat cache if the stream has a URI + if ($this->uri) { + clearstatcache(true, $this->uri); + } + + $stats = fstat($this->stream); + if (is_array($stats) && isset($stats['size'])) { + $this->size = $stats['size']; + + return $this->size; + } + + return null; + } + + public function isReadable(): bool + { + return $this->readable; + } + + public function isWritable(): bool + { + return $this->writable; + } + + public function isSeekable(): bool + { + return $this->seekable; + } + + public function eof(): bool + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + + return feof($this->stream); + } + + public function tell(): int + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + + $result = ftell($this->stream); + + if ($result === false) { + throw new \RuntimeException('Unable to determine stream position'); + } + + return $result; + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + $whence = (int) $whence; + + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + if (!$this->seekable) { + throw new \RuntimeException('Stream is not seekable'); + } + if (fseek($this->stream, $offset, $whence) === -1) { + throw new \RuntimeException('Unable to seek to stream position ' + .$offset.' with whence '.var_export($whence, true)); + } + } + + public function read($length): string + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); + } + if ($length < 0) { + throw new \RuntimeException('Length parameter cannot be negative'); + } + + if (0 === $length) { + return ''; + } + + try { + $string = fread($this->stream, $length); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to read from stream', 0, $e); + } + + if (false === $string) { + throw new \RuntimeException('Unable to read from stream'); + } + + return $string; + } + + public function write($string): int + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + if (!$this->writable) { + throw new \RuntimeException('Cannot write to a non-writable stream'); + } + + // We can't know the size after writing anything + $this->size = null; + $result = fwrite($this->stream, $string); + + if ($result === false) { + throw new \RuntimeException('Unable to write to stream'); + } + + return $result; + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + if (!isset($this->stream)) { + return $key ? null : []; + } elseif (!$key) { + return $this->customMetadata + stream_get_meta_data($this->stream); + } elseif (isset($this->customMetadata[$key])) { + return $this->customMetadata[$key]; + } + + $meta = stream_get_meta_data($this->stream); + + return $meta[$key] ?? null; + } +} diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php new file mode 100644 index 000000000..601c13afb --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php @@ -0,0 +1,156 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator trait + * + * @property StreamInterface $stream + */ +trait StreamDecoratorTrait +{ + /** + * @param StreamInterface $stream Stream to decorate + */ + public function __construct(StreamInterface $stream) + { + $this->stream = $stream; + } + + /** + * Magic method used to create a new stream if streams are not added in + * the constructor of a decorator (e.g., LazyOpenStream). + * + * @return StreamInterface + */ + public function __get(string $name) + { + if ($name === 'stream') { + $this->stream = $this->createStream(); + + return $this->stream; + } + + throw new \UnexpectedValueException("$name not found on class"); + } + + public function __toString(): string + { + try { + if ($this->isSeekable()) { + $this->seek(0); + } + + return $this->getContents(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function getContents(): string + { + return Utils::copyToString($this); + } + + /** + * Allow decorators to implement custom methods + * + * @return mixed + */ + public function __call(string $method, array $args) + { + /** @var callable $callable */ + $callable = [$this->stream, $method]; + $result = ($callable)(...$args); + + // Always return the wrapped object if the result is a return $this + return $result === $this->stream ? $this : $result; + } + + public function close(): void + { + $this->stream->close(); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + return $this->stream->getMetadata($key); + } + + public function detach() + { + return $this->stream->detach(); + } + + public function getSize(): ?int + { + return $this->stream->getSize(); + } + + public function eof(): bool + { + return $this->stream->eof(); + } + + public function tell(): int + { + return $this->stream->tell(); + } + + public function isReadable(): bool + { + return $this->stream->isReadable(); + } + + public function isWritable(): bool + { + return $this->stream->isWritable(); + } + + public function isSeekable(): bool + { + return $this->stream->isSeekable(); + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + $this->stream->seek($offset, $whence); + } + + public function read($length): string + { + return $this->stream->read($length); + } + + public function write($string): int + { + return $this->stream->write($string); + } + + /** + * Implement in subclasses to dynamically create streams when requested. + * + * @throws \BadMethodCallException + */ + protected function createStream(): StreamInterface + { + throw new \BadMethodCallException('Not implemented'); + } +} diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php new file mode 100644 index 000000000..77b04d747 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/StreamWrapper.php @@ -0,0 +1,207 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Converts Guzzle streams into PHP stream resources. + * + * @see https://www.php.net/streamwrapper + */ +final class StreamWrapper +{ + /** @var resource */ + public $context; + + /** @var StreamInterface */ + private $stream; + + /** @var string r, r+, or w */ + private $mode; + + /** + * Returns a resource representing the stream. + * + * @param StreamInterface $stream The stream to get a resource for + * + * @return resource + * + * @throws \InvalidArgumentException if stream is not readable or writable + */ + public static function getResource(StreamInterface $stream) + { + self::register(); + + if ($stream->isReadable()) { + $mode = $stream->isWritable() ? 'r+' : 'r'; + } elseif ($stream->isWritable()) { + $mode = 'w'; + } else { + throw new \InvalidArgumentException('The stream must be readable, ' + .'writable, or both.'); + } + + return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream)); + } + + /** + * Creates a stream context that can be used to open a stream as a php stream resource. + * + * @return resource + */ + public static function createStreamContext(StreamInterface $stream) + { + return stream_context_create([ + 'guzzle' => ['stream' => $stream], + ]); + } + + /** + * Registers the stream wrapper if needed + */ + public static function register(): void + { + if (!in_array('guzzle', stream_get_wrappers())) { + stream_wrapper_register('guzzle', __CLASS__); + } + } + + public function stream_open(string $path, string $mode, int $options, ?string &$opened_path = null): bool + { + $options = stream_context_get_options($this->context); + + if (!isset($options['guzzle']['stream'])) { + return false; + } + + $this->mode = $mode; + $this->stream = $options['guzzle']['stream']; + + return true; + } + + public function stream_read(int $count): string + { + return $this->stream->read($count); + } + + public function stream_write(string $data): int + { + return $this->stream->write($data); + } + + public function stream_tell(): int + { + return $this->stream->tell(); + } + + public function stream_eof(): bool + { + return $this->stream->eof(); + } + + public function stream_seek(int $offset, int $whence): bool + { + $this->stream->seek($offset, $whence); + + return true; + } + + /** + * @return resource|false + */ + public function stream_cast(int $cast_as) + { + $stream = clone $this->stream; + $resource = $stream->detach(); + + return $resource ?? false; + } + + /** + * @return array{ + * dev: int, + * ino: int, + * mode: int, + * nlink: int, + * uid: int, + * gid: int, + * rdev: int, + * size: int, + * atime: int, + * mtime: int, + * ctime: int, + * blksize: int, + * blocks: int + * }|false + */ + public function stream_stat() + { + if ($this->stream->getSize() === null) { + return false; + } + + static $modeMap = [ + 'r' => 33060, + 'rb' => 33060, + 'r+' => 33206, + 'w' => 33188, + 'wb' => 33188, + ]; + + return [ + 'dev' => 0, + 'ino' => 0, + 'mode' => $modeMap[$this->mode], + 'nlink' => 0, + 'uid' => 0, + 'gid' => 0, + 'rdev' => 0, + 'size' => $this->stream->getSize() ?: 0, + 'atime' => 0, + 'mtime' => 0, + 'ctime' => 0, + 'blksize' => 0, + 'blocks' => 0, + ]; + } + + /** + * @return array{ + * dev: int, + * ino: int, + * mode: int, + * nlink: int, + * uid: int, + * gid: int, + * rdev: int, + * size: int, + * atime: int, + * mtime: int, + * ctime: int, + * blksize: int, + * blocks: int + * } + */ + public function url_stat(string $path, int $flags): array + { + return [ + 'dev' => 0, + 'ino' => 0, + 'mode' => 0, + 'nlink' => 0, + 'uid' => 0, + 'gid' => 0, + 'rdev' => 0, + 'size' => 0, + 'atime' => 0, + 'mtime' => 0, + 'ctime' => 0, + 'blksize' => 0, + 'blocks' => 0, + ]; + } +} diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php new file mode 100644 index 000000000..d9b779f13 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -0,0 +1,211 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use InvalidArgumentException; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; +use RuntimeException; + +class UploadedFile implements UploadedFileInterface +{ + private const ERROR_MAP = [ + UPLOAD_ERR_OK => 'UPLOAD_ERR_OK', + UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE', + UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE', + UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL', + UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE', + UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR', + UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE', + UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION', + ]; + + /** + * @var string|null + */ + private $clientFilename; + + /** + * @var string|null + */ + private $clientMediaType; + + /** + * @var int + */ + private $error; + + /** + * @var string|null + */ + private $file; + + /** + * @var bool + */ + private $moved = false; + + /** + * @var int|null + */ + private $size; + + /** + * @var StreamInterface|null + */ + private $stream; + + /** + * @param StreamInterface|string|resource $streamOrFile + */ + public function __construct( + $streamOrFile, + ?int $size, + int $errorStatus, + ?string $clientFilename = null, + ?string $clientMediaType = null + ) { + $this->setError($errorStatus); + $this->size = $size; + $this->clientFilename = $clientFilename; + $this->clientMediaType = $clientMediaType; + + if ($this->isOk()) { + $this->setStreamOrFile($streamOrFile); + } + } + + /** + * Depending on the value set file or stream variable + * + * @param StreamInterface|string|resource $streamOrFile + * + * @throws InvalidArgumentException + */ + private function setStreamOrFile($streamOrFile): void + { + if (is_string($streamOrFile)) { + $this->file = $streamOrFile; + } elseif (is_resource($streamOrFile)) { + $this->stream = new Stream($streamOrFile); + } elseif ($streamOrFile instanceof StreamInterface) { + $this->stream = $streamOrFile; + } else { + throw new InvalidArgumentException( + 'Invalid stream or file provided for UploadedFile' + ); + } + } + + /** + * @throws InvalidArgumentException + */ + private function setError(int $error): void + { + if (!isset(UploadedFile::ERROR_MAP[$error])) { + throw new InvalidArgumentException( + 'Invalid error status for UploadedFile' + ); + } + + $this->error = $error; + } + + private static function isStringNotEmpty($param): bool + { + return is_string($param) && false === empty($param); + } + + /** + * Return true if there is no upload error + */ + private function isOk(): bool + { + return $this->error === UPLOAD_ERR_OK; + } + + public function isMoved(): bool + { + return $this->moved; + } + + /** + * @throws RuntimeException if is moved or not ok + */ + private function validateActive(): void + { + if (false === $this->isOk()) { + throw new RuntimeException(\sprintf('Cannot retrieve stream due to upload error (%s)', self::ERROR_MAP[$this->error])); + } + + if ($this->isMoved()) { + throw new RuntimeException('Cannot retrieve stream after it has already been moved'); + } + } + + public function getStream(): StreamInterface + { + $this->validateActive(); + + if ($this->stream instanceof StreamInterface) { + return $this->stream; + } + + /** @var string $file */ + $file = $this->file; + + return new LazyOpenStream($file, 'r+'); + } + + public function moveTo($targetPath): void + { + $this->validateActive(); + + if (false === self::isStringNotEmpty($targetPath)) { + throw new InvalidArgumentException( + 'Invalid path provided for move operation; must be a non-empty string' + ); + } + + if ($this->file) { + $this->moved = PHP_SAPI === 'cli' + ? rename($this->file, $targetPath) + : move_uploaded_file($this->file, $targetPath); + } else { + Utils::copyToStream( + $this->getStream(), + new LazyOpenStream($targetPath, 'w') + ); + + $this->moved = true; + } + + if (false === $this->moved) { + throw new RuntimeException( + sprintf('Uploaded file could not be moved to %s', $targetPath) + ); + } + } + + public function getSize(): ?int + { + return $this->size; + } + + public function getError(): int + { + return $this->error; + } + + public function getClientFilename(): ?string + { + return $this->clientFilename; + } + + public function getClientMediaType(): ?string + { + return $this->clientMediaType; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php new file mode 100644 index 000000000..a7cdfb003 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Uri.php @@ -0,0 +1,743 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use GuzzleHttp\Psr7\Exception\MalformedUriException; +use Psr\Http\Message\UriInterface; + +/** + * PSR-7 URI implementation. + * + * @author Michael Dowling + * @author Tobias Schultze + * @author Matthew Weier O'Phinney + */ +class Uri implements UriInterface, \JsonSerializable +{ + /** + * Absolute http and https URIs require a host per RFC 7230 Section 2.7 + * but in generic URIs the host can be empty. So for http(s) URIs + * we apply this default host when no host is given yet to form a + * valid URI. + */ + private const HTTP_DEFAULT_HOST = 'localhost'; + + private const DEFAULT_PORTS = [ + 'http' => 80, + 'https' => 443, + 'ftp' => 21, + 'gopher' => 70, + 'nntp' => 119, + 'news' => 119, + 'telnet' => 23, + 'tn3270' => 23, + 'imap' => 143, + 'pop' => 110, + 'ldap' => 389, + ]; + + /** + * Unreserved characters for use in a regex. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3 + */ + private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~'; + + /** + * Sub-delims for use in a regex. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 + */ + private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;='; + private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26']; + + /** @var string Uri scheme. */ + private $scheme = ''; + + /** @var string Uri user info. */ + private $userInfo = ''; + + /** @var string Uri host. */ + private $host = ''; + + /** @var int|null Uri port. */ + private $port; + + /** @var string Uri path. */ + private $path = ''; + + /** @var string Uri query string. */ + private $query = ''; + + /** @var string Uri fragment. */ + private $fragment = ''; + + /** @var string|null String representation */ + private $composedComponents; + + public function __construct(string $uri = '') + { + if ($uri !== '') { + $parts = self::parse($uri); + if ($parts === false) { + throw new MalformedUriException("Unable to parse URI: $uri"); + } + $this->applyParts($parts); + } + } + + /** + * UTF-8 aware \parse_url() replacement. + * + * The internal function produces broken output for non ASCII domain names + * (IDN) when used with locales other than "C". + * + * On the other hand, cURL understands IDN correctly only when UTF-8 locale + * is configured ("C.UTF-8", "en_US.UTF-8", etc.). + * + * @see https://bugs.php.net/bug.php?id=52923 + * @see https://www.php.net/manual/en/function.parse-url.php#114817 + * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING + * + * @return array|false + */ + private static function parse(string $url) + { + // If IPv6 + $prefix = ''; + if (preg_match('%^(.*://\[[0-9:a-fA-F]+\])(.*?)$%', $url, $matches)) { + /** @var array{0:string, 1:string, 2:string} $matches */ + $prefix = $matches[1]; + $url = $matches[2]; + } + + /** @var string */ + $encodedUrl = preg_replace_callback( + '%[^:/@?&=#]+%usD', + static function ($matches) { + return urlencode($matches[0]); + }, + $url + ); + + $result = parse_url($prefix.$encodedUrl); + + if ($result === false) { + return false; + } + + return array_map('urldecode', $result); + } + + public function __toString(): string + { + if ($this->composedComponents === null) { + $this->composedComponents = self::composeComponents( + $this->scheme, + $this->getAuthority(), + $this->path, + $this->query, + $this->fragment + ); + } + + return $this->composedComponents; + } + + /** + * Composes a URI reference string from its various components. + * + * Usually this method does not need to be called manually but instead is used indirectly via + * `Psr\Http\Message\UriInterface::__toString`. + * + * PSR-7 UriInterface treats an empty component the same as a missing component as + * getQuery(), getFragment() etc. always return a string. This explains the slight + * difference to RFC 3986 Section 5.3. + * + * Another adjustment is that the authority separator is added even when the authority is missing/empty + * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with + * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But + * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to + * that format). + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3 + */ + public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string + { + $uri = ''; + + // weak type checks to also accept null until we can add scalar type hints + if ($scheme != '') { + $uri .= $scheme.':'; + } + + if ($authority != '' || $scheme === 'file') { + $uri .= '//'.$authority; + } + + if ($authority != '' && $path != '' && $path[0] != '/') { + $path = '/'.$path; + } + + $uri .= $path; + + if ($query != '') { + $uri .= '?'.$query; + } + + if ($fragment != '') { + $uri .= '#'.$fragment; + } + + return $uri; + } + + /** + * Whether the URI has the default port of the current scheme. + * + * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used + * independently of the implementation. + */ + public static function isDefaultPort(UriInterface $uri): bool + { + return $uri->getPort() === null + || (isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]); + } + + /** + * Whether the URI is absolute, i.e. it has a scheme. + * + * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true + * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative + * to another URI, the base URI. Relative references can be divided into several forms: + * - network-path references, e.g. '//example.com/path' + * - absolute-path references, e.g. '/path' + * - relative-path references, e.g. 'subpath' + * + * @see Uri::isNetworkPathReference + * @see Uri::isAbsolutePathReference + * @see Uri::isRelativePathReference + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4 + */ + public static function isAbsolute(UriInterface $uri): bool + { + return $uri->getScheme() !== ''; + } + + /** + * Whether the URI is a network-path reference. + * + * A relative reference that begins with two slash characters is termed an network-path reference. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 + */ + public static function isNetworkPathReference(UriInterface $uri): bool + { + return $uri->getScheme() === '' && $uri->getAuthority() !== ''; + } + + /** + * Whether the URI is a absolute-path reference. + * + * A relative reference that begins with a single slash character is termed an absolute-path reference. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 + */ + public static function isAbsolutePathReference(UriInterface $uri): bool + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && isset($uri->getPath()[0]) + && $uri->getPath()[0] === '/'; + } + + /** + * Whether the URI is a relative-path reference. + * + * A relative reference that does not begin with a slash character is termed a relative-path reference. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 + */ + public static function isRelativePathReference(UriInterface $uri): bool + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); + } + + /** + * Whether the URI is a same-document reference. + * + * A same-document reference refers to a URI that is, aside from its fragment + * component, identical to the base URI. When no base URI is given, only an empty + * URI reference (apart from its fragment) is considered a same-document reference. + * + * @param UriInterface $uri The URI to check + * @param UriInterface|null $base An optional base URI to compare against + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4 + */ + public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool + { + if ($base !== null) { + $uri = UriResolver::resolve($base, $uri); + + return ($uri->getScheme() === $base->getScheme()) + && ($uri->getAuthority() === $base->getAuthority()) + && ($uri->getPath() === $base->getPath()) + && ($uri->getQuery() === $base->getQuery()); + } + + return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; + } + + /** + * Creates a new URI with a specific query string value removed. + * + * Any existing query string values that exactly match the provided key are + * removed. + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Query string key to remove. + */ + public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface + { + $result = self::getFilteredQueryString($uri, [$key]); + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a new URI with a specific query string value. + * + * Any existing query string values that exactly match the provided key are + * removed and replaced with the given key value pair. + * + * A value of null will set the query string key without a value, e.g. "key" + * instead of "key=value". + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Key to set. + * @param string|null $value Value to set + */ + public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface + { + $result = self::getFilteredQueryString($uri, [$key]); + + $result[] = self::generateQueryString($key, $value); + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a new URI with multiple specific query string values. + * + * It has the same behavior as withQueryValue() but for an associative array of key => value. + * + * @param UriInterface $uri URI to use as a base. + * @param (string|null)[] $keyValueArray Associative array of key and values + */ + public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface + { + $result = self::getFilteredQueryString($uri, array_keys($keyValueArray)); + + foreach ($keyValueArray as $key => $value) { + $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); + } + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a URI from a hash of `parse_url` components. + * + * @see https://www.php.net/manual/en/function.parse-url.php + * + * @throws MalformedUriException If the components do not form a valid URI. + */ + public static function fromParts(array $parts): UriInterface + { + $uri = new self(); + $uri->applyParts($parts); + $uri->validateState(); + + return $uri; + } + + public function getScheme(): string + { + return $this->scheme; + } + + public function getAuthority(): string + { + $authority = $this->host; + if ($this->userInfo !== '') { + $authority = $this->userInfo.'@'.$authority; + } + + if ($this->port !== null) { + $authority .= ':'.$this->port; + } + + return $authority; + } + + public function getUserInfo(): string + { + return $this->userInfo; + } + + public function getHost(): string + { + return $this->host; + } + + public function getPort(): ?int + { + return $this->port; + } + + public function getPath(): string + { + return $this->path; + } + + public function getQuery(): string + { + return $this->query; + } + + public function getFragment(): string + { + return $this->fragment; + } + + public function withScheme($scheme): UriInterface + { + $scheme = $this->filterScheme($scheme); + + if ($this->scheme === $scheme) { + return $this; + } + + $new = clone $this; + $new->scheme = $scheme; + $new->composedComponents = null; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withUserInfo($user, $password = null): UriInterface + { + $info = $this->filterUserInfoComponent($user); + if ($password !== null) { + $info .= ':'.$this->filterUserInfoComponent($password); + } + + if ($this->userInfo === $info) { + return $this; + } + + $new = clone $this; + $new->userInfo = $info; + $new->composedComponents = null; + $new->validateState(); + + return $new; + } + + public function withHost($host): UriInterface + { + $host = $this->filterHost($host); + + if ($this->host === $host) { + return $this; + } + + $new = clone $this; + $new->host = $host; + $new->composedComponents = null; + $new->validateState(); + + return $new; + } + + public function withPort($port): UriInterface + { + $port = $this->filterPort($port); + + if ($this->port === $port) { + return $this; + } + + $new = clone $this; + $new->port = $port; + $new->composedComponents = null; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withPath($path): UriInterface + { + $path = $this->filterPath($path); + + if ($this->path === $path) { + return $this; + } + + $new = clone $this; + $new->path = $path; + $new->composedComponents = null; + $new->validateState(); + + return $new; + } + + public function withQuery($query): UriInterface + { + $query = $this->filterQueryAndFragment($query); + + if ($this->query === $query) { + return $this; + } + + $new = clone $this; + $new->query = $query; + $new->composedComponents = null; + + return $new; + } + + public function withFragment($fragment): UriInterface + { + $fragment = $this->filterQueryAndFragment($fragment); + + if ($this->fragment === $fragment) { + return $this; + } + + $new = clone $this; + $new->fragment = $fragment; + $new->composedComponents = null; + + return $new; + } + + public function jsonSerialize(): string + { + return $this->__toString(); + } + + /** + * Apply parse_url parts to a URI. + * + * @param array $parts Array of parse_url parts to apply. + */ + private function applyParts(array $parts): void + { + $this->scheme = isset($parts['scheme']) + ? $this->filterScheme($parts['scheme']) + : ''; + $this->userInfo = isset($parts['user']) + ? $this->filterUserInfoComponent($parts['user']) + : ''; + $this->host = isset($parts['host']) + ? $this->filterHost($parts['host']) + : ''; + $this->port = isset($parts['port']) + ? $this->filterPort($parts['port']) + : null; + $this->path = isset($parts['path']) + ? $this->filterPath($parts['path']) + : ''; + $this->query = isset($parts['query']) + ? $this->filterQueryAndFragment($parts['query']) + : ''; + $this->fragment = isset($parts['fragment']) + ? $this->filterQueryAndFragment($parts['fragment']) + : ''; + if (isset($parts['pass'])) { + $this->userInfo .= ':'.$this->filterUserInfoComponent($parts['pass']); + } + + $this->removeDefaultPort(); + } + + /** + * @param mixed $scheme + * + * @throws \InvalidArgumentException If the scheme is invalid. + */ + private function filterScheme($scheme): string + { + if (!is_string($scheme)) { + throw new \InvalidArgumentException('Scheme must be a string'); + } + + return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); + } + + /** + * @param mixed $component + * + * @throws \InvalidArgumentException If the user info is invalid. + */ + private function filterUserInfoComponent($component): string + { + if (!is_string($component)) { + throw new \InvalidArgumentException('User info must be a string'); + } + + return preg_replace_callback( + '/(?:[^%'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.']+|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $component + ); + } + + /** + * @param mixed $host + * + * @throws \InvalidArgumentException If the host is invalid. + */ + private function filterHost($host): string + { + if (!is_string($host)) { + throw new \InvalidArgumentException('Host must be a string'); + } + + return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); + } + + /** + * @param mixed $port + * + * @throws \InvalidArgumentException If the port is invalid. + */ + private function filterPort($port): ?int + { + if ($port === null) { + return null; + } + + $port = (int) $port; + if (0 > $port || 0xFFFF < $port) { + throw new \InvalidArgumentException( + sprintf('Invalid port: %d. Must be between 0 and 65535', $port) + ); + } + + return $port; + } + + /** + * @param (string|int)[] $keys + * + * @return string[] + */ + private static function getFilteredQueryString(UriInterface $uri, array $keys): array + { + $current = $uri->getQuery(); + + if ($current === '') { + return []; + } + + $decodedKeys = array_map(function ($k): string { + return rawurldecode((string) $k); + }, $keys); + + return array_filter(explode('&', $current), function ($part) use ($decodedKeys) { + return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true); + }); + } + + private static function generateQueryString(string $key, ?string $value): string + { + // Query string separators ("=", "&") within the key or value need to be encoded + // (while preventing double-encoding) before setting the query string. All other + // chars that need percent-encoding will be encoded by withQuery(). + $queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); + + if ($value !== null) { + $queryString .= '='.strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); + } + + return $queryString; + } + + private function removeDefaultPort(): void + { + if ($this->port !== null && self::isDefaultPort($this)) { + $this->port = null; + } + } + + /** + * Filters the path of a URI + * + * @param mixed $path + * + * @throws \InvalidArgumentException If the path is invalid. + */ + private function filterPath($path): string + { + if (!is_string($path)) { + throw new \InvalidArgumentException('Path must be a string'); + } + + return preg_replace_callback( + '/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $path + ); + } + + /** + * Filters the query string or fragment of a URI. + * + * @param mixed $str + * + * @throws \InvalidArgumentException If the query or fragment is invalid. + */ + private function filterQueryAndFragment($str): string + { + if (!is_string($str)) { + throw new \InvalidArgumentException('Query and fragment must be a string'); + } + + return preg_replace_callback( + '/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $str + ); + } + + private function rawurlencodeMatchZero(array $match): string + { + return rawurlencode($match[0]); + } + + private function validateState(): void + { + if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { + $this->host = self::HTTP_DEFAULT_HOST; + } + + if ($this->getAuthority() === '') { + if (0 === strpos($this->path, '//')) { + throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"'); + } + if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { + throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon'); + } + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/UriComparator.php b/vendor/guzzlehttp/psr7/src/UriComparator.php new file mode 100644 index 000000000..70c582aa0 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UriComparator.php @@ -0,0 +1,52 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\UriInterface; + +/** + * Provides methods to determine if a modified URL should be considered cross-origin. + * + * @author Graham Campbell + */ +final class UriComparator +{ + /** + * Determines if a modified URL should be considered cross-origin with + * respect to an original URL. + */ + public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool + { + if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) { + return true; + } + + if ($original->getScheme() !== $modified->getScheme()) { + return true; + } + + if (self::computePort($original) !== self::computePort($modified)) { + return true; + } + + return false; + } + + private static function computePort(UriInterface $uri): int + { + $port = $uri->getPort(); + + if (null !== $port) { + return $port; + } + + return 'https' === $uri->getScheme() ? 443 : 80; + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/vendor/guzzlehttp/psr7/src/UriNormalizer.php new file mode 100644 index 000000000..e17455737 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UriNormalizer.php @@ -0,0 +1,220 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\UriInterface; + +/** + * Provides methods to normalize and compare URIs. + * + * @author Tobias Schultze + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6 + */ +final class UriNormalizer +{ + /** + * Default normalizations which only include the ones that preserve semantics. + */ + public const PRESERVING_NORMALIZATIONS = + self::CAPITALIZE_PERCENT_ENCODING | + self::DECODE_UNRESERVED_CHARACTERS | + self::CONVERT_EMPTY_PATH | + self::REMOVE_DEFAULT_HOST | + self::REMOVE_DEFAULT_PORT | + self::REMOVE_DOT_SEGMENTS; + + /** + * All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. + * + * Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b + */ + public const CAPITALIZE_PERCENT_ENCODING = 1; + + /** + * Decodes percent-encoded octets of unreserved characters. + * + * For consistency, percent-encoded octets in the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), + * hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and, + * when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers. + * + * Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/ + */ + public const DECODE_UNRESERVED_CHARACTERS = 2; + + /** + * Converts the empty path to "/" for http and https URIs. + * + * Example: http://example.org → http://example.org/ + */ + public const CONVERT_EMPTY_PATH = 4; + + /** + * Removes the default host of the given URI scheme from the URI. + * + * Only the "file" scheme defines the default host "localhost". + * All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` + * are equivalent according to RFC 3986. The first format is not accepted + * by PHPs stream functions and thus already normalized implicitly to the + * second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`. + * + * Example: file://localhost/myfile → file:///myfile + */ + public const REMOVE_DEFAULT_HOST = 8; + + /** + * Removes the default port of the given URI scheme from the URI. + * + * Example: http://example.org:80/ → http://example.org/ + */ + public const REMOVE_DEFAULT_PORT = 16; + + /** + * Removes unnecessary dot-segments. + * + * Dot-segments in relative-path references are not removed as it would + * change the semantics of the URI reference. + * + * Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html + */ + public const REMOVE_DOT_SEGMENTS = 32; + + /** + * Paths which include two or more adjacent slashes are converted to one. + * + * Webservers usually ignore duplicate slashes and treat those URIs equivalent. + * But in theory those URIs do not need to be equivalent. So this normalization + * may change the semantics. Encoded slashes (%2F) are not removed. + * + * Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html + */ + public const REMOVE_DUPLICATE_SLASHES = 64; + + /** + * Sort query parameters with their values in alphabetical order. + * + * However, the order of parameters in a URI may be significant (this is not defined by the standard). + * So this normalization is not safe and may change the semantics of the URI. + * + * Example: ?lang=en&article=fred → ?article=fred&lang=en + * + * Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the + * purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly. + */ + public const SORT_QUERY_PARAMETERS = 128; + + /** + * Returns a normalized URI. + * + * The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. + * This methods adds additional normalizations that can be configured with the $flags parameter. + * + * PSR-7 UriInterface cannot distinguish between an empty component and a missing component as + * getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are + * treated equivalent which is not necessarily true according to RFC 3986. But that difference + * is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well. + * + * @param UriInterface $uri The URI to normalize + * @param int $flags A bitmask of normalizations to apply, see constants + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2 + */ + public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS): UriInterface + { + if ($flags & self::CAPITALIZE_PERCENT_ENCODING) { + $uri = self::capitalizePercentEncoding($uri); + } + + if ($flags & self::DECODE_UNRESERVED_CHARACTERS) { + $uri = self::decodeUnreservedCharacters($uri); + } + + if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' + && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https') + ) { + $uri = $uri->withPath('/'); + } + + if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') { + $uri = $uri->withHost(''); + } + + if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) { + $uri = $uri->withPort(null); + } + + if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) { + $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath())); + } + + if ($flags & self::REMOVE_DUPLICATE_SLASHES) { + $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath())); + } + + if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') { + $queryKeyValues = explode('&', $uri->getQuery()); + sort($queryKeyValues); + $uri = $uri->withQuery(implode('&', $queryKeyValues)); + } + + return $uri; + } + + /** + * Whether two URIs can be considered equivalent. + * + * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also + * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be + * resolved against the same base URI. If this is not the case, determination of equivalence or difference of + * relative references does not mean anything. + * + * @param UriInterface $uri1 An URI to compare + * @param UriInterface $uri2 An URI to compare + * @param int $normalizations A bitmask of normalizations to apply, see constants + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1 + */ + public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS): bool + { + return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations); + } + + private static function capitalizePercentEncoding(UriInterface $uri): UriInterface + { + $regex = '/(?:%[A-Fa-f0-9]{2})++/'; + + $callback = function (array $match): string { + return strtoupper($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private static function decodeUnreservedCharacters(UriInterface $uri): UriInterface + { + $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; + + $callback = function (array $match): string { + return rawurldecode($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/vendor/guzzlehttp/psr7/src/UriResolver.php b/vendor/guzzlehttp/psr7/src/UriResolver.php new file mode 100644 index 000000000..3737be1e5 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UriResolver.php @@ -0,0 +1,211 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\UriInterface; + +/** + * Resolves a URI reference in the context of a base URI and the opposite way. + * + * @author Tobias Schultze + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5 + */ +final class UriResolver +{ + /** + * Removes dot segments from a path and returns the new path. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4 + */ + public static function removeDotSegments(string $path): string + { + if ($path === '' || $path === '/') { + return $path; + } + + $results = []; + $segments = explode('/', $path); + foreach ($segments as $segment) { + if ($segment === '..') { + array_pop($results); + } elseif ($segment !== '.') { + $results[] = $segment; + } + } + + $newPath = implode('/', $results); + + if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) { + // Re-add the leading slash if necessary for cases like "/.." + $newPath = '/'.$newPath; + } elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) { + // Add the trailing slash if necessary + // If newPath is not empty, then $segment must be set and is the last segment from the foreach + $newPath .= '/'; + } + + return $newPath; + } + + /** + * Converts the relative URI into a new URI that is resolved against the base URI. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2 + */ + public static function resolve(UriInterface $base, UriInterface $rel): UriInterface + { + if ((string) $rel === '') { + // we can simply return the same base URI instance for this same-document reference + return $base; + } + + if ($rel->getScheme() != '') { + return $rel->withPath(self::removeDotSegments($rel->getPath())); + } + + if ($rel->getAuthority() != '') { + $targetAuthority = $rel->getAuthority(); + $targetPath = self::removeDotSegments($rel->getPath()); + $targetQuery = $rel->getQuery(); + } else { + $targetAuthority = $base->getAuthority(); + if ($rel->getPath() === '') { + $targetPath = $base->getPath(); + $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); + } else { + if ($rel->getPath()[0] === '/') { + $targetPath = $rel->getPath(); + } else { + if ($targetAuthority != '' && $base->getPath() === '') { + $targetPath = '/'.$rel->getPath(); + } else { + $lastSlashPos = strrpos($base->getPath(), '/'); + if ($lastSlashPos === false) { + $targetPath = $rel->getPath(); + } else { + $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1).$rel->getPath(); + } + } + } + $targetPath = self::removeDotSegments($targetPath); + $targetQuery = $rel->getQuery(); + } + } + + return new Uri(Uri::composeComponents( + $base->getScheme(), + $targetAuthority, + $targetPath, + $targetQuery, + $rel->getFragment() + )); + } + + /** + * Returns the target URI as a relative reference from the base URI. + * + * This method is the counterpart to resolve(): + * + * (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) + * + * One use-case is to use the current request URI as base URI and then generate relative links in your documents + * to reduce the document size or offer self-contained downloadable document archives. + * + * $base = new Uri('http://example.com/a/b/'); + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. + * echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. + * + * This method also accepts a target that is already relative and will try to relativize it further. Only a + * relative-path reference will be returned as-is. + * + * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well + */ + public static function relativize(UriInterface $base, UriInterface $target): UriInterface + { + if ($target->getScheme() !== '' + && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') + ) { + return $target; + } + + if (Uri::isRelativePathReference($target)) { + // As the target is already highly relative we return it as-is. It would be possible to resolve + // the target with `$target = self::resolve($base, $target);` and then try make it more relative + // by removing a duplicate query. But let's not do that automatically. + return $target; + } + + if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) { + return $target->withScheme(''); + } + + // We must remove the path before removing the authority because if the path starts with two slashes, the URI + // would turn invalid. And we also cannot set a relative path before removing the authority, as that is also + // invalid. + $emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost(''); + + if ($base->getPath() !== $target->getPath()) { + return $emptyPathUri->withPath(self::getRelativePath($base, $target)); + } + + if ($base->getQuery() === $target->getQuery()) { + // Only the target fragment is left. And it must be returned even if base and target fragment are the same. + return $emptyPathUri->withQuery(''); + } + + // If the base URI has a query but the target has none, we cannot return an empty path reference as it would + // inherit the base query component when resolving. + if ($target->getQuery() === '') { + $segments = explode('/', $target->getPath()); + /** @var string $lastSegment */ + $lastSegment = end($segments); + + return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); + } + + return $emptyPathUri; + } + + private static function getRelativePath(UriInterface $base, UriInterface $target): string + { + $sourceSegments = explode('/', $base->getPath()); + $targetSegments = explode('/', $target->getPath()); + array_pop($sourceSegments); + $targetLastSegment = array_pop($targetSegments); + foreach ($sourceSegments as $i => $segment) { + if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) { + unset($sourceSegments[$i], $targetSegments[$i]); + } else { + break; + } + } + $targetSegments[] = $targetLastSegment; + $relativePath = str_repeat('../', count($sourceSegments)).implode('/', $targetSegments); + + // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./". + // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used + // as the first segment of a relative-path reference, as it would be mistaken for a scheme name. + if ('' === $relativePath || false !== strpos(explode('/', $relativePath, 2)[0], ':')) { + $relativePath = "./$relativePath"; + } elseif ('/' === $relativePath[0]) { + if ($base->getAuthority() != '' && $base->getPath() === '') { + // In this case an extra slash is added by resolve() automatically. So we must not add one here. + $relativePath = ".$relativePath"; + } else { + $relativePath = "./$relativePath"; + } + } + + return $relativePath; + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/vendor/guzzlehttp/psr7/src/Utils.php b/vendor/guzzlehttp/psr7/src/Utils.php new file mode 100644 index 000000000..7682d2cdc --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Utils.php @@ -0,0 +1,477 @@ +<?php + +declare(strict_types=1); + +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + +final class Utils +{ + /** + * Remove the items given by the keys, case insensitively from the data. + * + * @param (string|int)[] $keys + */ + public static function caselessRemove(array $keys, array $data): array + { + $result = []; + + foreach ($keys as &$key) { + $key = strtolower((string) $key); + } + + foreach ($data as $k => $v) { + if (!in_array(strtolower((string) $k), $keys)) { + $result[$k] = $v; + } + } + + return $result; + } + + /** + * Copy the contents of a stream into another stream until the given number + * of bytes have been read. + * + * @param StreamInterface $source Stream to read from + * @param StreamInterface $dest Stream to write to + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * + * @throws \RuntimeException on error. + */ + public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void + { + $bufferSize = 8192; + + if ($maxLen === -1) { + while (!$source->eof()) { + if (!$dest->write($source->read($bufferSize))) { + break; + } + } + } else { + $remaining = $maxLen; + while ($remaining > 0 && !$source->eof()) { + $buf = $source->read(min($bufferSize, $remaining)); + $len = strlen($buf); + if (!$len) { + break; + } + $remaining -= $len; + $dest->write($buf); + } + } + } + + /** + * Copy the contents of a stream into a string until the given number of + * bytes have been read. + * + * @param StreamInterface $stream Stream to read + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * + * @throws \RuntimeException on error. + */ + public static function copyToString(StreamInterface $stream, int $maxLen = -1): string + { + $buffer = ''; + + if ($maxLen === -1) { + while (!$stream->eof()) { + $buf = $stream->read(1048576); + if ($buf === '') { + break; + } + $buffer .= $buf; + } + + return $buffer; + } + + $len = 0; + while (!$stream->eof() && $len < $maxLen) { + $buf = $stream->read($maxLen - $len); + if ($buf === '') { + break; + } + $buffer .= $buf; + $len = strlen($buffer); + } + + return $buffer; + } + + /** + * Calculate a hash of a stream. + * + * This method reads the entire stream to calculate a rolling hash, based + * on PHP's `hash_init` functions. + * + * @param StreamInterface $stream Stream to calculate the hash for + * @param string $algo Hash algorithm (e.g. md5, crc32, etc) + * @param bool $rawOutput Whether or not to use raw output + * + * @throws \RuntimeException on error. + */ + public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string + { + $pos = $stream->tell(); + + if ($pos > 0) { + $stream->rewind(); + } + + $ctx = hash_init($algo); + while (!$stream->eof()) { + hash_update($ctx, $stream->read(1048576)); + } + + $out = hash_final($ctx, $rawOutput); + $stream->seek($pos); + + return $out; + } + + /** + * Clone and modify a request with the given changes. + * + * This method is useful for reducing the number of clones needed to mutate + * a message. + * + * The changes can be one of: + * - method: (string) Changes the HTTP method. + * - set_headers: (array) Sets the given headers. + * - remove_headers: (array) Remove the given headers. + * - body: (mixed) Sets the given body. + * - uri: (UriInterface) Set the URI. + * - query: (string) Set the query string value of the URI. + * - version: (string) Set the protocol version. + * + * @param RequestInterface $request Request to clone and modify. + * @param array $changes Changes to apply. + */ + public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface + { + if (!$changes) { + return $request; + } + + $headers = $request->getHeaders(); + + if (!isset($changes['uri'])) { + $uri = $request->getUri(); + } else { + // Remove the host header if one is on the URI + if ($host = $changes['uri']->getHost()) { + $changes['set_headers']['Host'] = $host; + + if ($port = $changes['uri']->getPort()) { + $standardPorts = ['http' => 80, 'https' => 443]; + $scheme = $changes['uri']->getScheme(); + if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) { + $changes['set_headers']['Host'] .= ':'.$port; + } + } + } + $uri = $changes['uri']; + } + + if (!empty($changes['remove_headers'])) { + $headers = self::caselessRemove($changes['remove_headers'], $headers); + } + + if (!empty($changes['set_headers'])) { + $headers = self::caselessRemove(array_keys($changes['set_headers']), $headers); + $headers = $changes['set_headers'] + $headers; + } + + if (isset($changes['query'])) { + $uri = $uri->withQuery($changes['query']); + } + + if ($request instanceof ServerRequestInterface) { + $new = (new ServerRequest( + $changes['method'] ?? $request->getMethod(), + $uri, + $headers, + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion(), + $request->getServerParams() + )) + ->withParsedBody($request->getParsedBody()) + ->withQueryParams($request->getQueryParams()) + ->withCookieParams($request->getCookieParams()) + ->withUploadedFiles($request->getUploadedFiles()); + + foreach ($request->getAttributes() as $key => $value) { + $new = $new->withAttribute($key, $value); + } + + return $new; + } + + return new Request( + $changes['method'] ?? $request->getMethod(), + $uri, + $headers, + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion() + ); + } + + /** + * Read a line from the stream up to the maximum allowed buffer length. + * + * @param StreamInterface $stream Stream to read from + * @param int|null $maxLength Maximum buffer length + */ + public static function readLine(StreamInterface $stream, ?int $maxLength = null): string + { + $buffer = ''; + $size = 0; + + while (!$stream->eof()) { + if ('' === ($byte = $stream->read(1))) { + return $buffer; + } + $buffer .= $byte; + // Break when a new line is found or the max length - 1 is reached + if ($byte === "\n" || ++$size === $maxLength - 1) { + break; + } + } + + return $buffer; + } + + /** + * Redact the password in the user info part of a URI. + */ + public static function redactUserInfo(UriInterface $uri): UriInterface + { + $userInfo = $uri->getUserInfo(); + + if (false !== ($pos = \strpos($userInfo, ':'))) { + return $uri->withUserInfo(\substr($userInfo, 0, $pos), '***'); + } + + return $uri; + } + + /** + * Create a new stream based on the input type. + * + * Options is an associative array that can contain the following keys: + * - metadata: Array of custom metadata. + * - size: Size of the stream. + * + * This method accepts the following `$resource` types: + * - `Psr\Http\Message\StreamInterface`: Returns the value as-is. + * - `string`: Creates a stream object that uses the given string as the contents. + * - `resource`: Creates a stream object that wraps the given PHP stream resource. + * - `Iterator`: If the provided value implements `Iterator`, then a read-only + * stream object will be created that wraps the given iterable. Each time the + * stream is read from, data from the iterator will fill a buffer and will be + * continuously called until the buffer is equal to the requested read size. + * Subsequent read calls will first read from the buffer and then call `next` + * on the underlying iterator until it is exhausted. + * - `object` with `__toString()`: If the object has the `__toString()` method, + * the object will be cast to a string and then a stream will be returned that + * uses the string value. + * - `NULL`: When `null` is passed, an empty stream object is returned. + * - `callable` When a callable is passed, a read-only stream object will be + * created that invokes the given callable. The callable is invoked with the + * number of suggested bytes to read. The callable can return any number of + * bytes, but MUST return `false` when there is no more data to return. The + * stream object that wraps the callable will invoke the callable until the + * number of requested bytes are available. Any additional bytes will be + * buffered and used in subsequent reads. + * + * @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data + * @param array{size?: int, metadata?: array} $options Additional options + * + * @throws \InvalidArgumentException if the $resource arg is not valid. + */ + public static function streamFor($resource = '', array $options = []): StreamInterface + { + if (is_scalar($resource)) { + $stream = self::tryFopen('php://temp', 'r+'); + if ($resource !== '') { + fwrite($stream, (string) $resource); + fseek($stream, 0); + } + + return new Stream($stream, $options); + } + + switch (gettype($resource)) { + case 'resource': + /* + * The 'php://input' is a special stream with quirks and inconsistencies. + * We avoid using that stream by reading it into php://temp + */ + + /** @var resource $resource */ + if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') { + $stream = self::tryFopen('php://temp', 'w+'); + stream_copy_to_stream($resource, $stream); + fseek($stream, 0); + $resource = $stream; + } + + return new Stream($resource, $options); + case 'object': + /** @var object $resource */ + if ($resource instanceof StreamInterface) { + return $resource; + } elseif ($resource instanceof \Iterator) { + return new PumpStream(function () use ($resource) { + if (!$resource->valid()) { + return false; + } + $result = $resource->current(); + $resource->next(); + + return $result; + }, $options); + } elseif (method_exists($resource, '__toString')) { + return self::streamFor((string) $resource, $options); + } + break; + case 'NULL': + return new Stream(self::tryFopen('php://temp', 'r+'), $options); + } + + if (is_callable($resource)) { + return new PumpStream($resource, $options); + } + + throw new \InvalidArgumentException('Invalid resource type: '.gettype($resource)); + } + + /** + * Safely opens a PHP stream resource using a filename. + * + * When fopen fails, PHP normally raises a warning. This function adds an + * error handler that checks for errors and throws an exception instead. + * + * @param string $filename File to open + * @param string $mode Mode used to open the file + * + * @return resource + * + * @throws \RuntimeException if the file cannot be opened + */ + public static function tryFopen(string $filename, string $mode) + { + $ex = null; + set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool { + $ex = new \RuntimeException(sprintf( + 'Unable to open "%s" using mode "%s": %s', + $filename, + $mode, + $errstr + )); + + return true; + }); + + try { + /** @var resource $handle */ + $handle = fopen($filename, $mode); + } catch (\Throwable $e) { + $ex = new \RuntimeException(sprintf( + 'Unable to open "%s" using mode "%s": %s', + $filename, + $mode, + $e->getMessage() + ), 0, $e); + } + + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $handle; + } + + /** + * Safely gets the contents of a given stream. + * + * When stream_get_contents fails, PHP normally raises a warning. This + * function adds an error handler that checks for errors and throws an + * exception instead. + * + * @param resource $stream + * + * @throws \RuntimeException if the stream cannot be read + */ + public static function tryGetContents($stream): string + { + $ex = null; + set_error_handler(static function (int $errno, string $errstr) use (&$ex): bool { + $ex = new \RuntimeException(sprintf( + 'Unable to read stream contents: %s', + $errstr + )); + + return true; + }); + + try { + /** @var string|false $contents */ + $contents = stream_get_contents($stream); + + if ($contents === false) { + $ex = new \RuntimeException('Unable to read stream contents'); + } + } catch (\Throwable $e) { + $ex = new \RuntimeException(sprintf( + 'Unable to read stream contents: %s', + $e->getMessage() + ), 0, $e); + } + + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $contents; + } + + /** + * Returns a UriInterface for the given value. + * + * This function accepts a string or UriInterface and returns a + * UriInterface for the given value. If the value is already a + * UriInterface, it is returned as-is. + * + * @param string|UriInterface $uri + * + * @throws \InvalidArgumentException + */ + public static function uriFor($uri): UriInterface + { + if ($uri instanceof UriInterface) { + return $uri; + } + + if (is_string($uri)) { + return new Uri($uri); + } + + throw new \InvalidArgumentException('URI must be a string or UriInterface'); + } +} diff --git a/vendor/macgirvin/http-message-signer/LICENSE b/vendor/macgirvin/http-message-signer/LICENSE new file mode 100644 index 000000000..36f87d3af --- /dev/null +++ b/vendor/macgirvin/http-message-signer/LICENSE @@ -0,0 +1,30 @@ +BSD 3-Clause License + +Copyright (c) 2025, Quantificant LLC <waitman@quantificant.com> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names + of its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/vendor/macgirvin/http-message-signer/README.md b/vendor/macgirvin/http-message-signer/README.md new file mode 100644 index 000000000..3e111f860 --- /dev/null +++ b/vendor/macgirvin/http-message-signer/README.md @@ -0,0 +1,121 @@ +# HTTP Message Signer (RFC 9421) + + +A PHP 8.1+ library for signing and verifying HTTP messages (requests or responses) per [RFC 9421](https://www.rfc-editor.org/rfc/rfc9421). + +This is a fork of quantificant/http-message-signer + +Supports: +- RSA-SHA256 +- Ed25519 +- HMAC-SHA256 +- PSR-7 requests (e.g., Guzzle) +- Optionally (recommended) calculate and verify body digest (content-digest header) + +Requirements: +- bakame/http-structured-fields +- psr/http-message + +## Note + +This is Alpha version please report issues. Thanks. Tested on PHP 8.4, should run fine on 8.1+ + +2025-05-28: Partially reversed the constructor change. + + +## Installation + +```bash +composer require macgirvin/http-message-signer +``` + + +## Notes + +An instance of a PSR-7 MessageInterface is passed to the sign and verify functions. This can be a RequestInterface or a ResponseInterface. Typically, this will be a RequestInterface. If your web framework does not supply a pre-populated PSR7-compatible request interface, you can quickly generate one using + +``` +use GuzzleHttp\Psr7\ServerRequest; + +$request = ServerRequest::fromGlobals(); +``` + +This would typically be used to verify a message. + +To sign a message, install the composer package guzzlehttp/psr7 and create an instance of `Request`. + +## Usage + +```php +use HttpSignature\HttpMessageSigner; +use GuzzleHttp\Psr7\Request; + +$request = new Request( + 'GET', + 'https://api.example.com/resource?bat&baz=3', + [ + 'Host' => 'api.example.com', + 'Date' => gmdate('D, d M Y H:i:s T'), + ...additional headers + ] +); + +$signer = (new HttpMessageSigner()) + ->setPrivateKey($privateKey) // only needed for signing + ->setPublicKey($publicKey) // only needed for verifying + ->setKeyId('https://example.com/dave#rsaKey') // required + ->setAlgorithm('rsa-sha256') // required + ->setCreated(time()) // recommended + ->setExpires(time() + 300) // optional, contentious + ->setNonce('xJJ9;ro.3*kidney`') // optional one-time token + ->setTag('fediverse') // optional app profile name + ->setSignatureId('sig1') // optional, default is sig1 + + +$request = $signer->signRequest('("@method" "@path" "host" "date")', $request); +$isValid = $signer->verifyRequest($request); +``` + +See full examples in `/tests`. + +## Structured Fields + +RFC9421 makes heavy use of HTTP Structured Fields (RFC8941/RFC9651). The syntax is very precise and unforgiving. + +The signRequest() method takes a structured InnerList of components to sign. These may be headers or derived fields. +The string will look something like the following (where `...` represents additional components): + +``` +'("header1" "header2" "@method" ...)' +``` + +and may include modifier parameters. These are represented as + +``` +'("@query-param";name="foo" "header2";sf "header3" ...)' +``` + +Parameters beginning with '@' are components derived from the HTTP request but may not be represented in the headers. Please review RFC9421 for precise definitions. + + +Using the 'sf' parameter on a component will treat a signature component as a Structured Field when normalising the string. + +However, parsing Structured Fields by adding the 'sf' parameter is likely to fail unless you know what `type` it is. A built-in table contains the type definition for a number of known stuctured header types. This list is probably incomplete. A method `addStructuredFieldTypes()` is available to add the type information so it can be successfullly parsed. This takes an array with key of the lowercase header name and a value; which is one of 'list', 'innerlist', 'parameters, 'dictionary', 'item'. If the header name is in the list and the 'sf' modifier is used, the header will be parsed as the Structured Field type indicated. + +If a Structured Field is declared as type 'dictionary'; it is suitable for use with the RFC9421 `key` parameter. Using this parameter will fail if the Structured Field type is unknown or has not been registered. + +The signRequest() and verifyRequest() methods both use an instance of MessageInterface. In nearly all cases, this will be the RequestInterface. However, when signing responses, the default will be the ResponseInterface, and if components are required from the RequestInterface, the :req parameter must be added to the field definition. + +To sign or verify an HTTP Response, use a ResponseInterface as the provided `$interface`, and provide the RequestInterface in `$originalRequest`. This is optional but will allow the `req` modifier to work correctly when signing Responses. + +## Known issues +Currently not implemented is the special handling of the `cookie` and `set-cookie` headers when using the `sf` modifier. For further information please see https://httpwg.org/http-extensions/draft-ietf-httpbis-retrofit.html and https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-20 (or later). It is planned to implement this once RFC6265bis is finalised as a new RFC. + +Also not currently implemented are some of the many signature algorithms; as we're currently focused primarily on rsa-sha256 and ed25519. + +Pull requests welcome. + + +## License + +BSD 3-Clause diff --git a/vendor/macgirvin/http-message-signer/TESTING b/vendor/macgirvin/http-message-signer/TESTING new file mode 100644 index 000000000..a04c516a2 --- /dev/null +++ b/vendor/macgirvin/http-message-signer/TESTING @@ -0,0 +1,5 @@ +Run Tests: + +$ composer require --dev phpunit/phpunit +$ vendor/bin/phpunit + diff --git a/vendor/macgirvin/http-message-signer/composer.json b/vendor/macgirvin/http-message-signer/composer.json new file mode 100644 index 000000000..8c02de2c6 --- /dev/null +++ b/vendor/macgirvin/http-message-signer/composer.json @@ -0,0 +1,27 @@ +{ + "name": "macgirvin/http-message-signer", + "description": "RFC 9421 HTTP Message Signer and Verifier for PSR-7 requests", + "type": "library", + "require": { + "php": "^8.1", + "psr/http-message": "^2.0", + "guzzlehttp/psr7": "^2.0", + "bakame/http-structured-fields": "^2.0", + "ext-openssl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "autoload": { + "psr-4": { + "HttpSignature\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "HttpSignature\\Tests\\": "tests/" + } + }, + "license": "BSD-3-Clause", + "minimum-stability": "stable" +} diff --git a/vendor/macgirvin/http-message-signer/phpunit.xml b/vendor/macgirvin/http-message-signer/phpunit.xml new file mode 100644 index 000000000..4149ce1a9 --- /dev/null +++ b/vendor/macgirvin/http-message-signer/phpunit.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.1/phpunit.xsd" + bootstrap="vendor/autoload.php" + displayDetailsOnTestsThatTriggerWarnings="true" + colors="true"> + + <testsuites> + <testsuite name="HttpSignature Test Suite"> + <directory>tests</directory> + </testsuite> + </testsuites> + + <source> + <include> + <directory>src</directory> + </include> + </source> + +</phpunit> diff --git a/vendor/macgirvin/http-message-signer/src/HttpMessageSigner.php b/vendor/macgirvin/http-message-signer/src/HttpMessageSigner.php new file mode 100644 index 000000000..977bed4cd --- /dev/null +++ b/vendor/macgirvin/http-message-signer/src/HttpMessageSigner.php @@ -0,0 +1,821 @@ +<?php + +namespace HttpSignature; + +use Bakame\Http\StructuredFields\InnerList; +use Bakame\Http\StructuredFields\Item; +use Bakame\Http\StructuredFields\OuterList; +use Bakame\Http\StructuredFields\Parameters; +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Bakame\Http\StructuredFields\Dictionary; + +class HttpMessageSigner +{ + private string $keyId; + private string $privateKey; + private string $publicKey; + private string $algorithm; + private string $signatureId = 'sig1'; + private string $created = ''; + private string $expires = ''; + private string $nonce = ''; + private string $tag = ''; + + private array $structuredFieldTypes = []; + + private $originalRequest; + + + public function __construct() + { + $this->setStructuredFieldTypes((new StructuredFieldTypes())->getFields()); + return $this; + } + + public function getHeaders($interface): array + { + $headers = []; + foreach ($interface->getHeaders() as $name => $values) { + $headers[strtolower($name)] = implode(', ', $values); + } + return $headers; + } + + + /* PSR-7 interface to signing function */ + + public function signRequest(string $coveredFields, MessageInterface $interface, RequestInterface $originalRequest = null): MessageInterface + { + $headers = $this->getHeaders($interface); + if ($originalRequest) { + $this->setOriginalRequest($originalRequest); + } + + $signedHeaders = $this->sign( + $headers, + $coveredFields, + $interface + ); + + foreach (['signature-input', 'signature'] as $header) { + $interface = $interface->withHeader($header, $signedHeaders[$header]); + } + return $interface; + } + + /* PSR-7 verify interface and also check body digest if included */ + + public function verifyRequest(MessageInterface $interface, RequestInterface $originalRequest = null): bool + { + $headers = []; + if ($originalRequest) { + $this->setOriginalRequest($originalRequest); + } + foreach ($interface->getHeaders() as $name => $values) { + $headers[strtolower($name)] = implode(', ', $values); + } + + /* check the body digest if it's present */ + + if (isset($headers['content-digest'])) { + $body = (string)$interface->getBody(); + if (!$this->isBodyDigestValid($body, $headers['content-digest'])) { + return false; + } + } + + return $this->verify($headers, $interface); + } + + /** + * check body digest + * + * From https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Digest + * The algorithm used to create a digest of the message content. Only two registered digest algorithms are + * considered secure: sha-512 and sha-256. The insecure (legacy) registered digest algorithms + * are: md5, sha (SHA-1), unixsum, unixcksum, adler (ADLER32) and crc32c. + */ + + private function isBodyDigestValid(string $body, string $headerValue): bool + { + if (!preg_match('/sha-(.*?)=:(.*?):/', $headerValue, $matches)) { + return false; + } + if (!in_array($matches[1], ['256', '512'], true)) { + return false; + } + + $algorithm = 'sha' . $matches[1]; + + $expectedDigest = base64_decode($matches[2]); + $actualDigest = hash($algorithm, $body, true); + + return hash_equals($expectedDigest, $actualDigest); + } + + /** + * @param array $headers + * @param string $coveredFields + * + * Can be used as a development function to peek into the internals of the exact things + * that were signed and/or test the internal results of data normalisation. + * This matches the sign() function except that it just returns the serialised string + * and does not sign it. + */ + public function calculateSignatureBase(array $headers, string $coveredFields, $interface) + { + $signatureComponents = []; + $processedComponents = []; + $dict = $this->parseStructuredDict($coveredFields); + + if ($dict->isNotEmpty()) { + $coveredStructuredFields = $dict->__toString(); + $indices = $dict->indices(); + foreach ($indices as $index) { + $member = $dict->getByIndex($index); + if (!$member) { + throw new \Exception('Index ' . $index . ' not found'); + } + if (in_array($member, $processedComponents, true)) { + throw new \Exception('Duplicate member found'); + } + $processedComponents[] = $member; + $signatureComponents[] = $this->canonicalizeComponent($member, $headers, $interface); + } + } + + $signatureInput = $coveredStructuredFields . ';keyid="' + . $this->keyId . '";alg="' . $this->algorithm . '"'; + + if ($this->created) { + $signatureInput .= ';created=' . $this->created; + } + if ($this->expires) { + $signatureInput .= ';expires=' . $this->expires; + } + if ($this->nonce) { + $signatureInput .= ';nonce="' . $this->nonce . '"'; + } + if ($this->tag) { + $signatureInput .= ';tag="' . $this->tag . '"'; + } + + + /** + * Always include @signature-params in the result. + */ + $signatureComponents[] = '"@signature-params": ' . $signatureInput; + + $signatureBase = implode("\n", $signatureComponents); + return $signatureBase; + + } + + public function sign(array $headers, string $coveredFields, MessageInterface $interface): array + { + $signatureComponents = []; + $processedComponents = []; + + $dict = $this->parseStructuredDict($coveredFields); + + if ($dict->isNotEmpty()) { + $coveredStructuredFields = $dict->__toString(); + $indices = $dict->indices(); + foreach ($indices as $index) { + $member = $dict->getByIndex($index); + if (!$member) { + throw new \Exception('Index ' . $index . ' not found'); + } + if (in_array($member, $processedComponents, true)) { + throw new \Exception('Duplicate member found'); + } + $processedComponents[] = $member; + $signatureComponents[] = $this->canonicalizeComponent($member, $headers, $interface); + } + } + + $signatureInput = $coveredStructuredFields . ';keyid="' + . $this->keyId . '";alg="' . $this->algorithm . '"' + . (($this->created) ? ';created=' . $this->created : '') + . (($this->expires) ? ';expires=' . $this->expires : '') + . (($this->nonce) ? ';nonce="' . $this->nonce . '"' : '') + . (($this->tag) ? ';tag="' . $this->tag . '"' : ''); + + /** + * Always include @signature-params in the result. + */ + $signatureComponents[] = '"@signature-params": ' . $signatureInput; + + $signatureBase = implode("\n", $signatureComponents); + $signature = $this->createSignature($signatureBase); + + $headers['signature-input'] = "$this->signatureId=$signatureInput"; + $headers['signature'] = "$this->signatureId=:$signature:"; + + return $headers; + } + + public function verify(array $headers, $interface): bool + { + if (!isset($headers['signature-input'], $headers['signature'])) { + return false; + } + $headers[] = 'signature-params'; + + $sigInputDict = $this->parseStructuredDict($headers['signature-input']); + + $signatureComponents = []; + + if ($sigInputDict->isNotEmpty()) { + $indices = $sigInputDict->indices(); + foreach ($indices as $index) { + [$dictName, $members] = $sigInputDict->getByIndex($index); + if ($members instanceof InnerList) { + $innerIndices = $members->indices(); + foreach ($innerIndices as $innerIndex) { + $member = $members->getByIndex($innerIndex); + $signatureComponents[$dictName][] = $this->canonicalizeComponent($member, $headers, $interface); + } + $parameters = $this->extractParameters($members); + + if (isset($parameters['expires'])) { + $expires = (int) $parameters['expires']; + if ($expires < time()) { + return false; + } + if (isset($parameters['created'])) { + $created = (int) $parameters['created']; + if ($created >= $expires) { + return false; + } + } + } + } + } + } + + $sigDict = $this->parseStructuredDict($headers['signature']); + if ($sigDict->isNotEmpty()) { + $indices = $sigDict->indices(); + foreach ($indices as $index) { + [$dictName, $members] = $sigDict->getByIndex($index); + if ($members instanceof Item) { + $signatures[$dictName] = $members->value(); + } + if ($members instanceof InnerList) { + $innerIndices = $members->indices(); + foreach ($innerIndices as $innerIndex) { + $signatures[$dictName][] = $members->getByIndex($innerIndex); + } + } + } + } + + foreach ($signatureComponents as $dictName => $dictComponents) { + $namedSignatureComponents = $signatureComponents[$dictName]; + $signatureParamsStr = $sigInputDict[$dictName]->toHttpValue(); + $namedSignatureComponents[] = '"@signature-params": ' . $signatureParamsStr; + $signatureBase = implode("\n", $namedSignatureComponents); + if (!isset($sigDict[$dictName])) { + return false; + } + + $decodedSig = base64_decode(trim($sigDict[$dictName]->__toString(), ':')); + return $this->verifySignature($signatureBase, $decodedSig, $params['alg'] ?? $this->algorithm); + } + return false; + } + + protected function extractParameters($field): array + { + $parameters = []; + $fieldParams = $field->parameters(); + + if ($fieldParams->isNotEmpty()) { + $indices = $fieldParams->indices(); + foreach ($indices as $index) { + [$name, $item] = $fieldParams->getByIndex($index); + $parameters[$name] = $item->value(); + } + } + return $parameters; + } + + private function canonicalizeComponent($field, array $headers, MessageInterface $interface): string + { + $fieldName = $field->value(); + $parameters = $this->extractParameters($field); + if (isset($parameters['bs']) && isset($parameters['sf'])) { + throw new \Exception('Cannot use both bs and sf'); + } + + $whichRequest = $interface; + if (isset($parameters['req']) && $interface instanceof ResponseInterface) { + $whichRequest = $this->getOriginalRequest(); + } + $whichHeaders = $headers; + + if (isset($parameters['tr'])) { + $whichHeaders = $whichRequest->getTrailers(); + } + + [$name, $value] = $this->getFieldValue($fieldName, $whichRequest, $whichHeaders, $parameters); + + if (isset($parameters['bs'])) { + $result = $name . ';bs: '; + $values = $whichRequest->getHeader($fieldName); + if (!$values) { + return ''; + } + if (!is_array($values)) { + $values = [$values]; + } + foreach ($values as $value) { + $value = trim($value); + $result .= ':' . base64_encode($value) . ':' . ', '; + } + return $values ? rtrim($result, ', ') : $result; + } + + if (isset($parameters['sf'])) { + $value = $this->applyStructuredField($name, $value); + return $name . ';sf: ' . $value; + } + if (isset($parameters['key'])) { + $childName = $parameters['key']; + $value = $this->applySingleKeyValue($name, $childName, $value); + return $name . ';key="' . $childName . '": ' . $value; + } + return $name . ': ' . $value; + } + + private function getFieldValue($fieldName, MessageInterface $interface, $headers, $parameters ): array + { + $value = match ($fieldName) { + '@signature-params' => ['', ''], + '@method' => ['"@method"', strtoupper($interface->getMethod())], + '@authority' => ['"@authority"', $interface->getUri()->getAuthority()], + '@scheme' => ['"@scheme"', strtolower($interface->getUri()->getScheme())], + '@target-uri' => ['"target-uri"', $interface->getUri()->__toString()], + '@request-target' => ['"@request-target"', $interface->getRequestTarget()], + '@path' => ['"@path"', $interface->getUri()->getPath()], + '@query' => ['"@query"', $interface->getUri()->getQuery()], + '@query-param' => $this->getQueryParam($interface, $parameters) ?? ['', ''], + '@status' => ['"@status"', '"@status": ' . $interface->getStatusCode()], + default => ['"' . $fieldName . '"', trim($headers[$fieldName] ?? '')], + }; + return $value; + } + + /** + * @param string $query + * @return array|null + * + * Should not use PHP's parse_str function here, as it has some issues with + * spaces and dots in parameter names. These are unlikely to occur, but the + * following function treats them as opaque strings rather than as variable + * names. + */ + private function parseQueryString(string $query): array|null + { + $result = []; + + if (!isset($query)) { + return null; + } + + $queryParams = explode('&', $query); + foreach ($queryParams as $param) { + // The '=' character is not required and indicates a boolean true value if unset. + $element = explode('=', $param, 2); + $result[urldecode($element[0])] = isset($element[1]) ? urldecode($element[1]) : ''; + } + return $result; + } + + /** + * @param $parameters + * @param $name + * @return string|null + * + * Find one query parameter by name (which must supplied as parameters in the (structured) covered field list). + */ + private function getQueryParam($whichRequest, array $parameters): array + { + $queryString = $whichRequest->getUri()->getQuery(); + if ($queryString) { + $queryParams = $this->parseQueryString($queryString); + $fieldName = $parameters['name']; + if ($fieldName) { + return ['"_' . $fieldName . '_"', $queryParams[$fieldName] ? '"' . $queryParams[$fieldName] . '"' : '']; + } + } + throw new \Exception('Query string named parameter not set'); + } + + private function applyStructuredField(string $name, string $fieldValue): string + { + $type = $this->structuredFieldTypes[trim($name, '"')]; + switch ($type) { + case 'list': + $field = OuterList::fromHttpValue($fieldValue); + break; + case 'innerlist': + $field = InnerList::fromHttpValue($fieldValue); + break; + case 'parameters': + $field = Parameters::fromHttpValue($fieldValue); + break; + case 'dictionary': + $field = Dictionary::fromHttpValue($fieldValue); + break; + case 'item': + $field = Item::fromHttpValue($fieldValue); + break; + case 'url': + return '"' . $fieldValue . '"'; + case 'date': + return '@' . strtotime($fieldValue); + case 'etag': + $result = ''; + $list = explode(',', $fieldValue); + foreach ($list as $item) { + if (str_starts_with(trim($item), 'W/')) { + $result .= substr(trim($item), 2) . '; w' . ', '; + } else { + $result .= trim($item) . ', '; + } + } + return rtrim($result, ', '); + case 'cookie': + // @TODO + default: + break; + } + if (!$field) { + return ''; + } + return $field->toHttpValue(); + } + + private function applySingleKeyValue(string $name, string $key, string $fieldValue): string + { + $type = $this->structuredFieldTypes[trim($name, '"')]; + if (empty($type) || $type === 'dictionary') { + $dictionary = Dictionary::fromHttpValue($fieldValue); + if ($dictionary->isNotEmpty() && isset($dictionary[$key])) { + return $dictionary[$key]->toHttpValue(); + } + } + return ''; + } + + private function applyByteSequence(string $fieldValue): string + { + return $fieldValue; + } + + private function applyTrailer(string $fieldValue): string + { + return $fieldValue; + } + + private function createSignature(string $data): string + { + return match ($this->algorithm) { + 'rsa-sha256' => $this->rsaSign($data), + 'ed25519' => $this->ed25519Sign($data), + 'hmac-sha256' => base64_encode(hash_hmac('sha256', $data, $this->privateKey, true)), + default => throw new \RuntimeException("Unsupported algorithm: $this->algorithm") + }; + } + + private function verifySignature(string $data, string $signature, string $alg): bool + { + return match ($alg) { + 'rsa-sha256' => openssl_verify($data, $signature, $this->publicKey, + OPENSSL_ALGO_SHA256) === 1, + 'ed25519' => openssl_verify($data, $signature, $this->publicKey, "Ed25519") === 1, + 'hmac-sha256' => hash_equals( + base64_encode(hash_hmac('sha256', $data, $this->privateKey, true)), + base64_encode($signature) + ), + default => false + }; + } + + /* sign with rsa or ed25519 */ + + private function rsaSign(string $data): string + { + if (!openssl_sign($data, $signature, $this->privateKey, OPENSSL_ALGO_SHA256)) { + throw new \RuntimeException("RSA signing failed"); + } + return base64_encode($signature); + } + + private function ed25519Sign(string $data): string + { + if (!openssl_sign($data, $signature, $this->privateKey, "Ed25519")) { + throw new \RuntimeException("Ed25519 signing failed"); + } + return base64_encode($signature); + } + + /* parse a structed dict */ + + private function parseStructuredDict(string $headerValue) + { + if (str_starts_with(trim($headerValue), '(')) { + return InnerList::fromHttpValue($headerValue); + } + else { + return Dictionary::fromHttpValue($headerValue); + } + } + + /* Recommended to calculate the digest of the body and add it to + covered headers and sign, but not required. Convenience function + to calculate the digest. + + ex: + + $digest = $signer->createContentDigestHeader($body); + $request = $request->withHeader('Content-Digest', $digest); + */ + + /** + * @param string $body + * @param $algorithm ('sha256' || 'sha512') + * @return string + * + * From https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Digest + * The algorithm used to create a digest of the message content. Only two registered digest algorithms are + * considered secure: sha-512 and sha-256. The insecure (legacy) registered digest algorithms + * are: md5, sha (SHA-1), unixsum, unixcksum, adler (ADLER32) and crc32c. + */ + + public function createContentDigestHeader(string $body, $algorithm = 'sha256'): string + { + $supportedAlgorithms = ['sha256' => 'sha-256', 'sha512' => 'sha-512']; + foreach ($supportedAlgorithms as $alg => $value) { + if ($alg === $algorithm) { + $algorithmHeaderString = $value; + break; + } + } + if (!isset($algorithmHeaderString)) { + throw new \RuntimeException("Unsupported algorithm: $algorithm"); + } + $digest = hash($algorithm, $body, true); + /** + * Output as structured field. + */ + return $algorithmHeaderString . '=:' . base64_encode($digest) . ':'; + } + + /* Convenience function, probably want to use a robust PSR7 solution instead */ + + public static function parseHttpMessage(string $raw): array + { + [$headerPart, $body] = explode("\r\n\r\n", $raw, 2); + $lines = explode("\r\n", $headerPart); + $requestLine = array_shift($lines); + [$method, $path] = explode(' ', $requestLine); + + $headers = []; + foreach ($lines as $line) { + [$name, $value] = explode(':', $line, 2); + $headers[strtolower(trim($name))] = trim($value); + } + + return [ + 'method' => $method, + 'path' => $path, + 'headers' => $headers, + 'body' => $body + ]; + } + + /** + * @return array + */ + public function getStructuredFieldTypes(): array + { + return $this->structuredFieldTypes; + } + + /** + * @param array $structuredFieldTypes + * @return HttpMessageSigner + */ + public function setStructuredFieldTypes(array $structuredFieldTypes): HttpMessageSigner + { + $this->structuredFieldTypes = $structuredFieldTypes; + return $this; + } + + /** + * $structuredFieldType consists of a key named after a specific header field, and a value + * which is one of 'list', 'innerlist', 'parameters, 'dictionary', 'item'. + * + * Example: + * ['example-dict' => 'dictionary'] + * + * The 'sf' flag will not be honoured unless the structured type of the header is registered/known. + * + * @param array $structuredFieldType + * @return $this + */ + + public function addStructuredFieldType(array $structuredFieldType): HttpMessageSigner + { + foreach ($structuredFieldType as $key => $value) { + $this->structuredFieldTypes[$key] = $value; + } + return $this; + } + + /** + * @return mixed + */ + public function getOriginalRequest() + { + return $this->originalRequest; + } + + /** + * @param mixed $originalRequest + * @return HttpMessageSigner + */ + public function setOriginalRequest($originalRequest) + { + $this->originalRequest = $originalRequest; + return $this; + } + + /** + * @return string + */ + public function getKeyId(): string + { + return $this->keyId; + } + + /** + * @param string $keyId + * @return HttpMessageSigner + */ + public function setKeyId(string $keyId): HttpMessageSigner + { + $this->keyId = $keyId; + return $this; + } + + /** + * @return string + */ + public function getPrivateKey(): string + { + return $this->privateKey; + } + + /** + * @param string $privateKey + * @return HttpMessageSigner + */ + public function setPrivateKey(string $privateKey): HttpMessageSigner + { + $this->privateKey = $privateKey; + return $this; + } + + /** + * @return string + */ + public function getPublicKey(): string + { + return $this->publicKey; + } + + /** + * @param string $publicKey + * @return HttpMessageSigner + */ + public function setPublicKey(string $publicKey): HttpMessageSigner + { + $this->publicKey = $publicKey; + return $this; + } + + /** + * @return string + */ + public function getAlgorithm(): string + { + return $this->algorithm; + } + + /** + * @param string $algorithm + * @return HttpMessageSigner + */ + public function setAlgorithm(string $algorithm): HttpMessageSigner + { + $this->algorithm = $algorithm; + return $this; + } + + /** + * @return string + */ + public function getSignatureId(): string + { + return $this->signatureId; + } + + /** + * @param string $signatureId + * @return HttpMessageSigner + */ + public function setSignatureId(string $signatureId): HttpMessageSigner + { + $this->signatureId = $signatureId; + return $this; + } + + /** + * @return string + */ + public function getCreated(): string + { + return $this->created; + } + + /** + * @param string $created + * @return HttpMessageSigner + */ + public function setCreated(string $created): HttpMessageSigner + { + $this->created = $created; + return $this; + } + + /** + * @return string + */ + public function getExpires(): string + { + return $this->expires; + } + + /** + * @param string $expires + * @return HttpMessageSigner + */ + public function setExpires(string $expires): HttpMessageSigner + { + $this->expires = $expires; + return $this; + } + + /** + * @return string + */ + public function getNonce(): string + { + return $this->nonce; + } + + /** + * @param string $nonce + * @return HttpMessageSigner + */ + public function setNonce(string $nonce): HttpMessageSigner + { + $this->nonce = $nonce; + return $this; + } + + /** + * @return string + */ + public function getTag(): string + { + return $this->tag; + } + + /** + * @param string $tag + * @return HttpMessageSigner + */ + public function setTag(string $tag): HttpMessageSigner + { + $this->tag = $tag; + return $this; + } +} + diff --git a/vendor/macgirvin/http-message-signer/src/StructuredFieldTypes.php b/vendor/macgirvin/http-message-signer/src/StructuredFieldTypes.php new file mode 100644 index 000000000..df70717f8 --- /dev/null +++ b/vendor/macgirvin/http-message-signer/src/StructuredFieldTypes.php @@ -0,0 +1,91 @@ +<?php +namespace HttpSignature; + + +class StructuredFieldTypes +{ + public function __construct() + { + return $this; + } + + public function getFields(): array + { + $returnValue = []; + $fields = explode("\n", $this->fieldlist); + foreach ($fields as $entry) { + $exploded = explode(" ", $entry); + $returnValue[$exploded[0]] = trim($exploded[1]); + } + return $returnValue; + } + + public $fieldlist = +'accept list +accept-encoding list +accept-language list +accept-patch list +accept-post list +accept-ranges list +access-control-allow-credentials item +access-control-allow-headers list +access-control-allow-methods list +access-control-allow-origin item +access-control-expose-headers list +access-control-max-age item +access-control-request-headers list +access-control-request-method item +age item +allow list +alpn list +alt-svc dictionary +alt-used item +cache-control dictionary +cdn-loop list +clear-site-data list +connection list +content-encoding list +content-language list +content-length list +content-location url +content-type item +cookie cookie +cross-origin-resource-policy item +date date +dnt item +etag etag +expect dictionary +expect-ct dictionary +expires date +host item +if-match etag +if-modified-since date +if-none-match etag +if-unmodified-since date +keep-alive dictionary +last-modified date +location url +max-forwards item +origin item +pragma dictionary +prefer dictionary +preference-applied dictionary +referer url +retry-after item +sec-websocket-extensions list +sec-websocket-protocol list +sec-websocket-version item +server-timing list +set-cookie cookie +surrogate-control dictionary +te list +timing-allow-origin list +trailer list +transfer-encoding list +upgrade-insecure-requests item +vary list +x-content-type-options item +x-frame-options item +x-xss-protection list'; + +}
\ No newline at end of file diff --git a/vendor/ralouphie/getallheaders/LICENSE b/vendor/ralouphie/getallheaders/LICENSE new file mode 100644 index 000000000..be5540c2a --- /dev/null +++ b/vendor/ralouphie/getallheaders/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Ralph Khattar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/ralouphie/getallheaders/README.md b/vendor/ralouphie/getallheaders/README.md new file mode 100644 index 000000000..9430d76bb --- /dev/null +++ b/vendor/ralouphie/getallheaders/README.md @@ -0,0 +1,27 @@ +getallheaders +============= + +PHP `getallheaders()` polyfill. Compatible with PHP >= 5.3. + +[](https://travis-ci.org/ralouphie/getallheaders) +[](https://coveralls.io/r/ralouphie/getallheaders?branch=master) +[](https://packagist.org/packages/ralouphie/getallheaders) +[](https://packagist.org/packages/ralouphie/getallheaders) +[](https://packagist.org/packages/ralouphie/getallheaders) + + +This is a simple polyfill for [`getallheaders()`](http://www.php.net/manual/en/function.getallheaders.php). + +## Install + +For PHP version **`>= 5.6`**: + +``` +composer require ralouphie/getallheaders +``` + +For PHP version **`< 5.6`**: + +``` +composer require ralouphie/getallheaders "^2" +``` diff --git a/vendor/ralouphie/getallheaders/composer.json b/vendor/ralouphie/getallheaders/composer.json new file mode 100644 index 000000000..de8ce62e4 --- /dev/null +++ b/vendor/ralouphie/getallheaders/composer.json @@ -0,0 +1,26 @@ +{ + "name": "ralouphie/getallheaders", + "description": "A polyfill for getallheaders.", + "license": "MIT", + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^5 || ^6.5", + "php-coveralls/php-coveralls": "^2.1" + }, + "autoload": { + "files": ["src/getallheaders.php"] + }, + "autoload-dev": { + "psr-4": { + "getallheaders\\Tests\\": "tests/" + } + } +} diff --git a/vendor/ralouphie/getallheaders/src/getallheaders.php b/vendor/ralouphie/getallheaders/src/getallheaders.php new file mode 100644 index 000000000..c7285a5ba --- /dev/null +++ b/vendor/ralouphie/getallheaders/src/getallheaders.php @@ -0,0 +1,46 @@ +<?php + +if (!function_exists('getallheaders')) { + + /** + * Get all HTTP header key/values as an associative array for the current request. + * + * @return string[string] The HTTP header key/value pairs. + */ + function getallheaders() + { + $headers = array(); + + $copy_server = array( + 'CONTENT_TYPE' => 'Content-Type', + 'CONTENT_LENGTH' => 'Content-Length', + 'CONTENT_MD5' => 'Content-Md5', + ); + + foreach ($_SERVER as $key => $value) { + if (substr($key, 0, 5) === 'HTTP_') { + $key = substr($key, 5); + if (!isset($copy_server[$key]) || !isset($_SERVER[$key])) { + $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $key)))); + $headers[$key] = $value; + } + } elseif (isset($copy_server[$key])) { + $headers[$copy_server[$key]] = $value; + } + } + + if (!isset($headers['Authorization'])) { + if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) { + $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; + } elseif (isset($_SERVER['PHP_AUTH_USER'])) { + $basic_pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; + $headers['Authorization'] = 'Basic ' . base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $basic_pass); + } elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) { + $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST']; + } + } + + return $headers; + } + +} diff --git a/view/css/conversation.css b/view/css/conversation.css index 3d206797f..38970bb45 100644 --- a/view/css/conversation.css +++ b/view/css/conversation.css @@ -244,7 +244,7 @@ a.wall-item-name-link { top: 0; left: 0; border-color: var(--hz-item-indent, var(--bs-border-color)); - border-radius: 0 var(--bs-border-radius) 0 0; + border-radius: 0 1.5rem 0 0; border-style: solid; border-width: 1px 1px 0 0; } diff --git a/view/js/main.js b/view/js/main.js index b1cae8fb8..5bf7234aa 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -894,15 +894,22 @@ function updateConvItems(mode, data) { let data_json = JSON.parse(elem.dataset.b64mids); - // Also highlight the thread parent - if (data_json.includes(bParam_mid) && elem.parentNode.classList.contains('wall-item-sub-thread-wrapper')) { - if (!elem.parentNode.parentNode.classList.contains('toplevel_item')) { + if (elem.parentNode.classList.contains('wall-item-sub-thread-wrapper') && elem.parentNode.children.length) { + // Set the highlight state + if (data_json.includes(bParam_mid) && !elem.parentNode.parentNode.classList.contains('toplevel_item')) { elem.parentNode.parentNode.classList.add('item-highlight'); document.documentElement.style.setProperty('--hz-item-highlight', stringToHslColor(JSON.parse(elem.parentNode.parentNode.dataset.b64mids)[0])); - // Mark the comment button at the parent expanded - // TODO: should do that for all comments that have replies expanded - elem.parentNode.parentNode.querySelector('.wall-item-comment').classList.add('expanded'); } + + let elemSubThreadWrapper = elem.querySelector('.wall-item-sub-thread-wrapper'); + let elemCommentButton = elem.querySelector('.wall-item-comment'); + + // Set the button and sub-thread-wrapper state + if (elemCommentButton && elemSubThreadWrapper.children.length) { + elemCommentButton.classList.add('expanded'); + } + + elem.parentNode.classList.add('item-expanded'); } b64mids.push(...data_json); diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index 113660c7e..be66c00d4 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -88,6 +88,7 @@ } else { if (!document.hidden) { + sse_fallback(); sse_fallback_interval = setInterval(sse_fallback, updateInterval); } |