Stop accessing the ->userAgent property of the session
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 14 Oct 2020 12:20:02 +0000 (14:20 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 15 Oct 2020 14:14:14 +0000 (16:14 +0200)
Use UserUtil::getUserAgent() instead.

wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php

index 3ec0af5d03531fa24bbd677f7a4d194f65bd41dc..5e57fc40ed25759438215ea0aba80d7f1a49a4a9 100644 (file)
@@ -505,7 +505,7 @@ class WCF {
                        }
                }
                if (defined('BLACKLIST_USER_AGENTS') && BLACKLIST_USER_AGENTS != '') {
-                       if (!StringUtil::executeWordFilter(self::getSession()->userAgent, BLACKLIST_USER_AGENTS)) {
+                       if (!StringUtil::executeWordFilter(UserUtil::getUserAgent(), BLACKLIST_USER_AGENTS)) {
                                if ($isAjax) {
                                        throw new AJAXException(self::getLanguage()->getDynamicVariable('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                                }
index 2135cae4465c7a0f51479f79e8826d7e759c524f..ccdfaf02c43e5cdea9a32cfea6b4ecbeed452d54 100644 (file)
@@ -44,7 +44,7 @@ class SessionAccessLogListener implements IParameterizedEventListener {
                                        'userID' => WCF::getUser()->userID,
                                        'ipAddress' => UserUtil::getIpAddress(),
                                        'hostname' => @gethostbyaddr(UserUtil::getIpAddress()),
-                                       'userAgent' => WCF::getSession()->userAgent,
+                                       'userAgent' => UserUtil::getUserAgent(),
                                        'time' => TIME_NOW,
                                        'lastActivityTime' => TIME_NOW
                                ]);