Merge pull request #14671 from MrPetovan/bug/14469-content-after-post

Force exits in PushSubscription PUT, POST and DELETE handlers
This commit is contained in:
Michael Vogel 2025-01-07 23:29:47 +01:00 committed by GitHub
commit 275b383be7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 120 additions and 121 deletions

View file

@ -223,17 +223,17 @@ abstract class BaseModule implements ICanHandleRequests
switch ($this->args->getMethod()) { switch ($this->args->getMethod()) {
case Router::DELETE: case Router::DELETE:
$this->delete($request); $this->delete($request);
return $this->response->generate(); break;
case Router::PATCH: case Router::PATCH:
$this->patch($request); $this->patch($request);
return $this->response->generate(); break;
case Router::POST: case Router::POST:
Core\Hook::callAll($this->args->getModuleName() . '_mod_post', $request); Core\Hook::callAll($this->args->getModuleName() . '_mod_post', $request);
$this->post($request); $this->post($request);
return $this->response->generate(); break;
case Router::PUT: case Router::PUT:
$this->put($request); $this->put($request);
return $this->response->generate(); break;
case Router::GET: case Router::GET:
$this->get($request); $this->get($request);
break; break;

View file

@ -92,6 +92,6 @@ class UpdateCredentials extends BaseApi
} }
$account = DI::mstdnAccount()->createFromContactId($ucid, $uid); $account = DI::mstdnAccount()->createFromContactId($ucid, $uid);
$this->response->addJsonContent($account->toArray()); $this->jsonExit($account->toArray());
} }
} }

View file

@ -66,7 +66,7 @@ class PushSubscription extends BaseApi
$this->logger->info('Subscription stored', ['ret' => $ret, 'subscription' => $subscription]); $this->logger->info('Subscription stored', ['ret' => $ret, 'subscription' => $subscription]);
$subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid); $subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid);
$this->response->addJsonContent($subscriptionObj->toArray()); $this->jsonExit($subscriptionObj->toArray());
} }
public function put(array $request = []): void public function put(array $request = []): void
@ -105,7 +105,7 @@ class PushSubscription extends BaseApi
]); ]);
$subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid); $subscriptionObj = $this->subscriptionFac->createForApplicationIdAndUserId($application['id'], $uid);
$this->response->addJsonContent($subscriptionObj->toArray()); $this->jsonExit($subscriptionObj->toArray());
} }
private function setBoolean($input): bool private function setBoolean($input): bool
@ -130,7 +130,7 @@ class PushSubscription extends BaseApi
'uid' => $uid, 'uid' => $uid,
]); ]);
$this->response->addJsonContent([]); $this->jsonExit([]);
} }
protected function get(array $request = []): void protected function get(array $request = []): void

View file

@ -165,7 +165,6 @@ class Install extends BaseModule
break; break;
} }
DI::baseUrl()->redirect('install?pass=' . $this->currentWizardStep);
} }
protected function content(array $request = []): string protected function content(array $request = []): string
@ -282,10 +281,12 @@ class Install extends BaseModule
$this->configCache->get('config', 'admin_email'), $this->configCache->get('config', 'admin_email'),
$this->t('Your account email address must match this in order to use the web admin panel.'), $this->t('Your account email address must match this in order to use the web admin panel.'),
$this->t('Required'), 'autofocus', 'email'], $this->t('Required'), 'autofocus', 'email'],
'$timezone' => Temporal::getTimezoneField('system-default_timezone', '$timezone' => Temporal::getTimezoneField(
'system-default_timezone',
$this->t('Please select a default timezone for your website'), $this->t('Please select a default timezone for your website'),
$this->configCache->get('system', 'default_timezone'), $this->configCache->get('system', 'default_timezone'),
''), ''
),
'$language' => ['system-language', '$language' => ['system-language',
$this->t('System Language:'), $this->t('System Language:'),
$this->configCache->get('system', 'language'), $this->configCache->get('system', 'language'),

View file

@ -77,8 +77,7 @@ class AppSpecific extends BaseSettings
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); $this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} else { } else {
$this->appSpecificPassword = AppSpecificPassword::generateForUser($this->session->getLocalUserId(), $request['description'] ?? ''); $this->appSpecificPassword = AppSpecificPassword::generateForUser($this->session->getLocalUserId(), $request['description'] ?? '');
$this->systemMessages->addInfo($this->t('New app-specific password generated: %s', $this->appSpecificPassword['plaintext_password'])); $this->systemMessages->addInfo($this->t('New app-specific password generated.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} }
break; break;

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2025.02-dev\n" "Project-Id-Version: 2025.02-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-01 23:33+0000\n" "POT-Creation-Date: 2025-01-04 20:55-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -646,7 +646,7 @@ msgstr ""
msgid "Map" msgid "Map"
msgstr "" msgstr ""
#: src/App.php:397 #: src/App.php:394
msgid "Apologies but the website is unavailable at the moment." msgid "Apologies but the website is unavailable at the moment."
msgstr "" msgstr ""
@ -765,15 +765,15 @@ msgstr ""
msgid "No system theme config value set." msgid "No system theme config value set."
msgstr "" msgstr ""
#: src/BaseModule.php:393 #: src/BaseModule.php:395
msgid "The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before submitting it." msgid "The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before submitting it."
msgstr "" msgstr ""
#: src/BaseModule.php:420 #: src/BaseModule.php:422
msgid "All contacts" msgid "All contacts"
msgstr "" msgstr ""
#: src/BaseModule.php:425 src/Content/Conversation/Factory/Channel.php:32 #: src/BaseModule.php:427 src/Content/Conversation/Factory/Channel.php:32
#: src/Content/Widget.php:254 src/Core/ACL.php:182 src/Module/Contact.php:395 #: src/Content/Widget.php:254 src/Core/ACL.php:182 src/Module/Contact.php:395
#: src/Module/Privacy/PermissionTooltip.php:150 #: src/Module/Privacy/PermissionTooltip.php:150
#: src/Module/Privacy/PermissionTooltip.php:172 #: src/Module/Privacy/PermissionTooltip.php:172
@ -781,16 +781,16 @@ msgstr ""
msgid "Followers" msgid "Followers"
msgstr "" msgstr ""
#: src/BaseModule.php:430 src/Content/Widget.php:255 src/Module/Contact.php:398 #: src/BaseModule.php:432 src/Content/Widget.php:255 src/Module/Contact.php:398
#: src/Module/Settings/Channels.php:145 #: src/Module/Settings/Channels.php:145
msgid "Following" msgid "Following"
msgstr "" msgstr ""
#: src/BaseModule.php:435 src/Content/Widget.php:256 src/Module/Contact.php:401 #: src/BaseModule.php:437 src/Content/Widget.php:256 src/Module/Contact.php:401
msgid "Mutual friends" msgid "Mutual friends"
msgstr "" msgstr ""
#: src/BaseModule.php:443 #: src/BaseModule.php:445
msgid "Common" msgid "Common"
msgstr "" msgstr ""
@ -1835,7 +1835,7 @@ msgstr ""
msgid "Create new group" msgid "Create new group"
msgstr "" msgstr ""
#: src/Content/Item.php:322 src/Model/Item.php:3281 #: src/Content/Item.php:322 src/Model/Item.php:3297
msgid "event" msgid "event"
msgstr "" msgstr ""
@ -1843,7 +1843,7 @@ msgstr ""
msgid "status" msgid "status"
msgstr "" msgstr ""
#: src/Content/Item.php:331 src/Model/Item.php:3283 #: src/Content/Item.php:331 src/Model/Item.php:3299
#: src/Module/Post/Tag/Add.php:109 #: src/Module/Post/Tag/Add.php:109
msgid "photo" msgid "photo"
msgstr "" msgstr ""
@ -2040,7 +2040,7 @@ msgid "Create an account"
msgstr "" msgstr ""
#: src/Content/Nav.php:247 src/Module/Help.php:53 #: src/Content/Nav.php:247 src/Module/Help.php:53
#: src/Module/Settings/TwoFactor/AppSpecific.php:119 #: src/Module/Settings/TwoFactor/AppSpecific.php:118
#: src/Module/Settings/TwoFactor/Index.php:125 #: src/Module/Settings/TwoFactor/Index.php:125
#: src/Module/Settings/TwoFactor/Recovery.php:96 #: src/Module/Settings/TwoFactor/Recovery.php:96
#: src/Module/Settings/TwoFactor/Verify.php:135 view/theme/vier/theme.php:228 #: src/Module/Settings/TwoFactor/Verify.php:135 view/theme/vier/theme.php:228
@ -2245,8 +2245,8 @@ msgstr ""
msgid "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s" msgid "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:926 src/Model/Item.php:4080 #: src/Content/Text/BBCode.php:926 src/Model/Item.php:4096
#: src/Model/Item.php:4086 src/Model/Item.php:4087 #: src/Model/Item.php:4102 src/Model/Item.php:4103
msgid "Link to source" msgid "Link to source"
msgstr "" msgstr ""
@ -2834,7 +2834,7 @@ msgstr ""
msgid "Could not connect to database." msgid "Could not connect to database."
msgstr "" msgstr ""
#: src/Core/L10n.php:426 src/Model/Item.php:2324 #: src/Core/L10n.php:426 src/Model/Item.php:2340
msgid "Undetermined" msgid "Undetermined"
msgstr "" msgstr ""
@ -3376,92 +3376,92 @@ msgstr ""
msgid "Happy Birthday %s" msgid "Happy Birthday %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2331 #: src/Model/Item.php:2347
#, php-format #, php-format
msgid "%s (%s - %s): %s" msgid "%s (%s - %s): %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2333 #: src/Model/Item.php:2349
#, php-format #, php-format
msgid "%s (%s): %s" msgid "%s (%s): %s"
msgstr "" msgstr ""
#: src/Model/Item.php:2336 #: src/Model/Item.php:2352
#, php-format #, php-format
msgid "" msgid ""
"Detected languages in this post:\n" "Detected languages in this post:\n"
"%s" "%s"
msgstr "" msgstr ""
#: src/Model/Item.php:3285 #: src/Model/Item.php:3301
msgid "activity" msgid "activity"
msgstr "" msgstr ""
#: src/Model/Item.php:3287 #: src/Model/Item.php:3303
msgid "comment" msgid "comment"
msgstr "" msgstr ""
#: src/Model/Item.php:3290 src/Module/Post/Tag/Add.php:109 #: src/Model/Item.php:3306 src/Module/Post/Tag/Add.php:109
msgid "post" msgid "post"
msgstr "" msgstr ""
#: src/Model/Item.php:3463 #: src/Model/Item.php:3479
#, php-format #, php-format
msgid "%s is blocked" msgid "%s is blocked"
msgstr "" msgstr ""
#: src/Model/Item.php:3465 #: src/Model/Item.php:3481
#, php-format #, php-format
msgid "%s is ignored" msgid "%s is ignored"
msgstr "" msgstr ""
#: src/Model/Item.php:3467 #: src/Model/Item.php:3483
#, php-format #, php-format
msgid "Content from %s is collapsed" msgid "Content from %s is collapsed"
msgstr "" msgstr ""
#: src/Model/Item.php:3471 #: src/Model/Item.php:3487
msgid "Sensitive content" msgid "Sensitive content"
msgstr "" msgstr ""
#: src/Model/Item.php:3980 #: src/Model/Item.php:3996
msgid "bytes" msgid "bytes"
msgstr "" msgstr ""
#: src/Model/Item.php:4011 #: src/Model/Item.php:4027
#, php-format #, php-format
msgid "%2$s (%3$d%%, %1$d vote)" msgid "%2$s (%3$d%%, %1$d vote)"
msgid_plural "%2$s (%3$d%%, %1$d votes)" msgid_plural "%2$s (%3$d%%, %1$d votes)"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:4013 #: src/Model/Item.php:4029
#, php-format #, php-format
msgid "%2$s (%1$d vote)" msgid "%2$s (%1$d vote)"
msgid_plural "%2$s (%1$d votes)" msgid_plural "%2$s (%1$d votes)"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:4018 #: src/Model/Item.php:4034
#, php-format #, php-format
msgid "%d voter. Poll end: %s" msgid "%d voter. Poll end: %s"
msgid_plural "%d voters. Poll end: %s" msgid_plural "%d voters. Poll end: %s"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:4020 #: src/Model/Item.php:4036
#, php-format #, php-format
msgid "%d voter." msgid "%d voter."
msgid_plural "%d voters." msgid_plural "%d voters."
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Model/Item.php:4022 #: src/Model/Item.php:4038
#, php-format #, php-format
msgid "Poll end: %s" msgid "Poll end: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:4063 src/Model/Item.php:4064 #: src/Model/Item.php:4079 src/Model/Item.php:4080
msgid "View on separate page" msgid "View on separate page"
msgstr "" msgstr ""
@ -9544,7 +9544,7 @@ msgstr ""
#: src/Module/Settings/Channels.php:177 src/Module/Settings/Channels.php:198 #: src/Module/Settings/Channels.php:177 src/Module/Settings/Channels.php:198
#: src/Module/Settings/Display.php:350 #: src/Module/Settings/Display.php:350
#: src/Module/Settings/TwoFactor/AppSpecific.php:124 #: src/Module/Settings/TwoFactor/AppSpecific.php:123
msgid "Description" msgid "Description"
msgstr "" msgstr ""
@ -10446,55 +10446,54 @@ msgid "App-specific password generation failed: This description already exists.
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:80 #: src/Module/Settings/TwoFactor/AppSpecific.php:80
#, php-format msgid "New app-specific password generated."
msgid "New app-specific password generated: %s"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:87 #: src/Module/Settings/TwoFactor/AppSpecific.php:86
msgid "App-specific passwords successfully revoked." msgid "App-specific passwords successfully revoked."
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:97 #: src/Module/Settings/TwoFactor/AppSpecific.php:96
msgid "App-specific password successfully revoked." msgid "App-specific password successfully revoked."
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:118 #: src/Module/Settings/TwoFactor/AppSpecific.php:117
msgid "Two-factor app-specific passwords" msgid "Two-factor app-specific passwords"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:120 #: src/Module/Settings/TwoFactor/AppSpecific.php:119
msgid "<p>App-specific passwords are randomly generated passwords used instead your regular password to authenticate your account on third-party applications that don't support two-factor authentication.</p>" msgid "<p>App-specific passwords are randomly generated passwords used instead your regular password to authenticate your account on third-party applications that don't support two-factor authentication.</p>"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:121 #: src/Module/Settings/TwoFactor/AppSpecific.php:120
msgid "Make sure to copy your new app-specific password now. You wont be able to see it again!" msgid "Make sure to copy your new app-specific password now. You wont be able to see it again!"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:125 #: src/Module/Settings/TwoFactor/AppSpecific.php:124
msgid "Last Used" msgid "Last Used"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:126 #: src/Module/Settings/TwoFactor/AppSpecific.php:125
msgid "Revoke" msgid "Revoke"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:127 #: src/Module/Settings/TwoFactor/AppSpecific.php:126
msgid "Revoke All" msgid "Revoke All"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:130 #: src/Module/Settings/TwoFactor/AppSpecific.php:129
msgid "When you generate a new app-specific password, you must use it right away, it will be shown to you once after you generate it." msgid "When you generate a new app-specific password, you must use it right away, it will be shown to you once after you generate it."
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:131 #: src/Module/Settings/TwoFactor/AppSpecific.php:130
msgid "Generate new app-specific password" msgid "Generate new app-specific password"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:132 #: src/Module/Settings/TwoFactor/AppSpecific.php:131
msgid "Friendiqa on my Fairphone 2..." msgid "Friendiqa on my Fairphone 2..."
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:133 #: src/Module/Settings/TwoFactor/AppSpecific.php:132
msgid "Generate" msgid "Generate"
msgstr "" msgstr ""