Merge remote-tracking branch 'origin/6.0'
authorOlaf Braun <info@braun-development.de>
Thu, 25 Apr 2024 14:43:17 +0000 (16:43 +0200)
committerOlaf Braun <info@braun-development.de>
Thu, 25 Apr 2024 14:43:17 +0000 (16:43 +0200)
# Conflicts:
# com.woltlab.wcf/package.xml
# syncTemplates.json
# wcfsetup/install/files/js/WoltLabSuite.Core.min.js
# wcfsetup/install/files/lib/action/FacebookAuthAction.class.php
# wcfsetup/install/files/lib/action/GithubAuthAction.class.php
# wcfsetup/install/files/lib/action/GoogleAuthAction.class.php
# wcfsetup/install/files/lib/action/TwitterAuthAction.class.php
# wcfsetup/install/files/lib/system/WCF.class.php
# wcfsetup/install/files/lib/system/html/node/HtmlNodeUnfurlLink.class.php
# wcfsetup/install/lang/de.xml
# wcfsetup/install/lang/en.xml

1  2 
spiderList/spiderList.xml
wcfsetup/install/files/acp/templates/styleAdd.tpl
wcfsetup/install/files/lib/action/FacebookAuthAction.class.php
wcfsetup/install/files/lib/action/GithubAuthAction.class.php
wcfsetup/install/files/lib/action/GoogleAuthAction.class.php
wcfsetup/install/files/lib/action/TwitterAuthAction.class.php
wcfsetup/install/files/lib/system/bbcode/WoltLabSuiteMediaBBCode.class.php
wcfsetup/install/files/lib/system/html/node/HtmlNodeUnfurlLink.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

Simple merge
index 712c160d4be2f921645555c11978c514075f9455,48c6f960d099f5b1bb8bcacc92f558b81490db94..f61ddcfaff863e27d43c2f6edc842c51d7a7fde2
@@@ -15,9 -24,18 +15,11 @@@ use wcf\util\StringUtil
   * @copyright   2001-2021 WoltLab GmbH
   * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
   */
 -final class FacebookAuthAction extends AbstractOauth2Action
 +final class FacebookAuthAction extends AbstractOauth2AuthAction
  {
 -    /**
 -     * @inheritDoc
 -     */
 -    public $neededModules = ['FACEBOOK_PUBLIC_KEY', 'FACEBOOK_PRIVATE_KEY'];
 -
 -    /**
 -     * @inheritDoc
 -     */
+     const AVAILABLE_DURING_OFFLINE_MODE = true;
 +    #[\Override]
      protected function getTokenEndpoint(): string
      {
          return 'https://graph.facebook.com/oauth/access_token';
index dca386951e228416a382c89f1c2755bac3596090,ff2adf402f7a9daad7305cdd2c2025a2da779741..d22c60745c5a9c6436a126964b2b297372a66178
@@@ -17,9 -25,18 +17,11 @@@ use wcf\util\StringUtil
   * @copyright   2001-2021 WoltLab GmbH
   * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
   */
 -final class GithubAuthAction extends AbstractOauth2Action
 +final class GithubAuthAction extends AbstractOauth2AuthAction
  {
 -    /**
 -     * @inheritDoc
 -     */
 -    public $neededModules = ['GITHUB_PUBLIC_KEY', 'GITHUB_PRIVATE_KEY'];
 -
 -    /**
 -     * @inheritDoc
 -     */
+     const AVAILABLE_DURING_OFFLINE_MODE = true;
 +    #[\Override]
      protected function getTokenEndpoint(): string
      {
          return 'https://github.com/login/oauth/access_token';
index 105abef8d7ba5dffbcc0b1a9d7160e93aadbfec0,8e90108073bfa8d11d4f8770c6363a0a7bf9249e..ba8bd180dd0257f22f8abc37ae3585693a27daa5
@@@ -15,9 -24,19 +15,11 @@@ use wcf\util\StringUtil
   * @copyright   2001-2021 WoltLab GmbH
   * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
   */
 -final class GoogleAuthAction extends AbstractOauth2Action
 +final class GoogleAuthAction extends AbstractOauth2AuthAction
  {
 -    /**
 -     * @inheritDoc
 -     */
 -    public $neededModules = ['GOOGLE_PUBLIC_KEY', 'GOOGLE_PRIVATE_KEY'];
 -
 -    /**
 -     * @var array
 -     */
 -    private $configuration;
+     const AVAILABLE_DURING_OFFLINE_MODE = true;
 +    private array $configuration;
  
      /**
       * Returns Google's OpenID Connect configuration.
index a89da37c24a989e4c7e630be7f546bc5d6604fd2,aad33737d210e57c79e3ae14ec0d7a1172ed336f..de9d676fcfa2c4ad54dbac1360045549ff7fa934
@@@ -27,72 -31,141 +27,74 @@@ use wcf\util\StringUtil
   * @copyright   2001-2021 WoltLab GmbH
   * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
   */
 -final class TwitterAuthAction extends AbstractAction
 +final class TwitterAuthAction extends AbstractOauth2AuthAction
  {
 -    /**
 -     * @inheritDoc
 -     */
 -    public $neededModules = ['TWITTER_PUBLIC_KEY', 'TWITTER_PRIVATE_KEY'];
+     const AVAILABLE_DURING_OFFLINE_MODE = true;
 +    #[\Override]
 +    protected function getClientId(): string
 +    {
 +        return StringUtil::trim(TWITTER_PUBLIC_KEY);
 +    }
  
 -    private ClientInterface $httpClient;
 +    #[\Override]
 +    protected function getClientSecret(): string
 +    {
 +        return StringUtil::trim(TWITTER_PRIVATE_KEY);
 +    }
  
 -    /**
 -     * @inheritDoc
 -     */
 -    public function readParameters()
 +    #[\Override]
 +    protected function getCallbackUrl(): string
      {
 -        parent::readParameters();
 +        return LinkHandler::getInstance()->getControllerLink(self::class);
 +    }
  
 -        if (WCF::getSession()->spiderID) {
 -            throw new PermissionDeniedException();
 -        }
 +    #[\Override]
 +    protected function getTokenEndpoint(): string
 +    {
 +        return 'https://api.twitter.com/oauth/access_token';
      }
  
 -    /**
 -     * @inheritDoc
 -     */
 -    public function execute(): ResponseInterface
 +    #[\Override]
 +    protected function supportsState(): bool
      {
 -        parent::execute();
 +        return false;
 +    }
  
 -        try {
 -            if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
 -                $token = $this->verifierToAccessToken(
 -                    $_GET['oauth_token'],
 -                    $_GET['oauth_verifier']
 -                );
 -
 -                $oauthUser = $this->getUser($token);
 -
 -                return $this->processUser($oauthUser);
 -            } elseif (isset($_GET['denied'])) {
 -                throw new NamedUserException(
 -                    WCF::getLanguage()->getDynamicVariable('wcf.user.3rdparty.login.error.denied')
 -                );
 -            } else {
 -                return $this->initiate();
 -            }
 -        } catch (NamedUserException | PermissionDeniedException $e) {
 -            throw $e;
 -        } catch (StateValidationException $e) {
 -            throw new NamedUserException(WCF::getLanguage()->getDynamicVariable(
 -                'wcf.user.3rdparty.login.error.stateValidation'
 -            ));
 -        } catch (\Exception $e) {
 -            $exceptionID = \wcf\functions\exception\logThrowable($e);
 -
 -            $type = 'genericException';
 -            if ($e instanceof ClientExceptionInterface) {
 -                $type = 'httpError';
 -            }
 +    #[\Override]
 +    protected function getProviderName(): string
 +    {
 +        return 'twitter';
 +    }
  
 -            throw new NamedUserException(WCF::getLanguage()->getDynamicVariable(
 -                'wcf.user.3rdparty.login.error.' . $type,
 -                [
 -                    'exceptionID' => $exceptionID,
 -                ]
 -            ));
 -        }
 +    #[\Override]
 +    protected function getScope(): string
 +    {
 +        // Twitter OAuth 1.0a does not support scopes
 +        return '';
 +    }
  
 -        throw new \LogicException("Unreachable");
 +    #[\Override]
 +    protected function getAuthorizeUrl(): string
 +    {
 +        return 'https://api.twitter.com/oauth/authenticate';
      }
  
 -    /**
 -     * Processes the user (e.g. by registering session variables and redirecting somewhere).
 -     */
 -    protected function processUser(OauthUser $oauthUser): ResponseInterface
 +    #[\Override]
 +    protected function mapParameters(ServerRequestInterface $request): OAuth2Success | OAuth2Failure | null
      {
 -        $user = User::getUserByAuthData('twitter:' . $oauthUser->getId());
 -
 -        if ($user->userID) {
 -            if (WCF::getUser()->userID) {
 -                // This account belongs to an existing user, but we are already logged in.
 -                // This can't be handled.
 -
 -                throw new NamedUserException(
 -                    WCF::getLanguage()->getDynamicVariable('wcf.user.3rdparty.twitter.connect.error.inuse')
 -                );
 -            } else {
 -                // This account belongs to an existing user, we are not logged in.
 -                // Perform the login.
 -
 -                WCF::getSession()->changeUser($user);
 -                WCF::getSession()->update();
 -                EventHandler::getInstance()->fire(
 -                    new UserLoggedIn($user)
 -                );
 -
 -                return new RedirectResponse(
 -                    LinkHandler::getInstance()->getLink()
 -                );
 -            }
 -        } else {
 -            WCF::getSession()->register('__3rdPartyProvider', 'twitter');
 -
 -            if (WCF::getUser()->userID) {
 -                // This account does not belong to anyone and we are already logged in.
 -                // Thus we want to connect this account.
 -
 -                WCF::getSession()->register('__oauthUser', $oauthUser);
 -
 -                return new RedirectResponse(
 -                    LinkHandler::getInstance()->getControllerLink(
 -                        AccountManagementForm::class,
 -                        [],
 -                        '#3rdParty'
 -                    )
 -                );
 -            } else {
 -                // This account does not belong to anyone and we are not logged in.
 -                // Thus we want to connect this account to a newly registered user.
 -
 -                WCF::getSession()->register('__oauthUser', $oauthUser);
 -                WCF::getSession()->register('__username', $oauthUser->getUsername());
 -                WCF::getSession()->register('__email', $oauthUser->getEmail());
 -
 -                // We assume that bots won't register an external account first, so
 -                // we skip the captcha.
 -                WCF::getSession()->register('noRegistrationCaptcha', true);
 -
 -                WCF::getSession()->update();
 -
 -                return new RedirectResponse(
 -                    LinkHandler::getInstance()->getControllerLink(RegisterForm::class)
 -                );
 -            }
 +        try {
 +            $mapper = (new MapperBuilder())
 +                ->allowSuperfluousKeys()
 +                ->enableFlexibleCasting()
 +                ->mapper();
 +
 +            return $mapper->map(
 +                \sprintf("%s|%s", OAuth2TwitterSuccess::class, OAuth2TwitterFailure::class),
 +                $request->getQueryParams()
 +            );
 +        } catch (\Throwable) {
 +            return null;
          }
      }
  
index 45cbf8d87948ffd0b61ca045522e127802c98675,90d9a6984dd8287aa4afceca901b5ec39d5e5450..ff384a19ce3044ae97badc12d7629a0cc8707226
@@@ -61,12 -57,13 +61,13 @@@ final class WoltLabSuiteMediaBBCode ext
              }
  
              if ($parser->getOutputType() == 'text/html') {
+                 $float = (!empty($openingTag['attributes'][2])) ? $openingTag['attributes'][2] : 'none';
                  if ($media->isImage) {
                      $thumbnailSize = (!empty($openingTag['attributes'][1])) ? $openingTag['attributes'][1] : 'original';
-                     $float = (!empty($openingTag['attributes'][2])) ? $openingTag['attributes'][2] : 'none';
                      $width = (!empty($openingTag['attributes'][3])) ? $openingTag['attributes'][3] : 'auto';
  
 -                    return WCF::getTPL()->fetch('mediaBBCodeTag', 'wcf', [
 +                    return WCF::getTPL()->fetch('shared_bbcode_wsm', 'wcf', [
                          'mediaLink' => $this->getLink($media),
                          'removeLinks' => $removeLinks,
                          'thumbnailLink' => $thumbnailSize !== 'original' ? $this->getThumbnailLink(
                          'width' => $width,
                      ]);
                  } elseif ($media->isVideo() || $media->isAudio()) {
 -                    return WCF::getTPL()->fetch('mediaBBCodeTag', 'wcf', [
 +                    return WCF::getTPL()->fetch('shared_bbcode_wsm', 'wcf', [
                          'mediaLink' => $this->getLink($media),
                          'removeLinks' => $removeLinks,
-                         'float' => 'none',
+                         'float' => $float,
                          'media' => $media->getLocalizedVersion(MessageEmbeddedObjectManager::getInstance()->getActiveMessageLanguageID()),
                          'width' => 'auto',
                      ]);
index 0a14654cdf4b8cb20e4586cfa7dc4fa33b7cbed5,558dc5eb90df65ab6eda95c6257cebb3a1093723..89565cb61b84efe4518a5a15cc0311ce487ebc51
@@@ -46,10 -66,14 +66,14 @@@ class HtmlNodeUnfurlLink extends HtmlNo
  
          self::removeStyling($link);
  
-         $url = self::lowercaseHostname($link->href);
-         $urlID = self::findOrCreate($url);
+         $object = new UnfurlUrlAction([], 'findOrCreate', [
+             'data' => [
+                 'url' => $uri->__toString(),
+             ],
+         ]);
+         $returnValues = $object->executeAction();
  
 -        $link->link->setAttribute(self::UNFURL_URL_ID_ATTRIBUTE_NAME, $returnValues['returnValues']->urlID);
 +        $link->link->setAttribute(self::UNFURL_URL_ID_ATTRIBUTE_NAME, $urlID);
      }
  
      private static function removeStyling(HtmlNodePlainLink $element): void
Simple merge
Simple merge