1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00
This commit is contained in:
e-adrien 2025-06-23 10:28:08 +02:00 committed by GitHub
commit d05993458d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 6 deletions

View file

@ -28,6 +28,8 @@ parameters:
mailer_dsn: smtp://127.0.0.1
wallabag_user_agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.92 Safari/535.2"
locale: en
# A secret key that's used to generate certain security-related tokens

View file

@ -31,6 +31,7 @@ services:
$supportUrl: '@=service(''craue_config'').get(''wallabag_support_url'')'
$fonts: '%wallabag.fonts%'
$defaultIgnoreOriginInstanceRules: '%wallabag.default_ignore_origin_instance_rules%'
$defaultUserAgent: "%wallabag_user_agent%"
Wallabag\:
resource: '../../src/*'
@ -206,6 +207,8 @@ services:
$config:
error_message: '%wallabag.fetching_error_message%'
error_message_title: '%wallabag.fetching_error_message_title%'
http_client:
ua_browser: "%wallabag_user_agent%"
$client: '@psr18.wallabag.client'
calls:
- [ setLogger, [ "@logger" ] ]

View file

@ -14,6 +14,7 @@ class LoginFormAuthenticator
public function __construct(
private readonly HttpBrowser $browser,
AuthenticatorProvider $authenticatorProvider,
private readonly string $defaultUserAgent,
) {
$this->expressionLanguage = new ExpressionLanguage(null, [$authenticatorProvider]);
}
@ -84,6 +85,10 @@ class LoginFormAuthenticator
$headers["HTTP_$headerName"] = $headerValue;
}
if (empty($headers['HTTP_user-agent'])) {
$headers['HTTP_user-agent'] = $this->defaultUserAgent;
}
return $headers;
}

View file

@ -37,7 +37,7 @@ class LoginFormAuthenticatorTest extends TestCase
$requestHtmlFunctionClient = new MockHttpClient([$requestHtmlFunctionResponse]);
$authenticatorProvider = new AuthenticatorProvider($requestHtmlFunctionClient);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider, 'Wallabag (Symfony HttpClient/5)');
$res = $auth->login($siteConfig);
@ -68,7 +68,7 @@ class LoginFormAuthenticatorTest extends TestCase
$requestHtmlFunctionClient = new MockHttpClient([$requestHtmlFunctionResponse]);
$authenticatorProvider = new AuthenticatorProvider($requestHtmlFunctionClient);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider, 'Wallabag (Symfony HttpClient/5)');
$res = $auth->login($siteConfig);
@ -126,7 +126,7 @@ class LoginFormAuthenticatorTest extends TestCase
;
$authenticatorProvider = new AuthenticatorProvider($requestHtmlFunctionClient);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider, 'Wallabag (Symfony HttpClient/5)');
$res = $auth->login($siteConfig);
@ -151,7 +151,7 @@ class LoginFormAuthenticatorTest extends TestCase
$requestHtmlFunctionClient = new MockHttpClient([$requestHtmlFunctionResponse]);
$authenticatorProvider = new AuthenticatorProvider($requestHtmlFunctionClient);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider, 'Wallabag (Symfony HttpClient/5)');
$loginRequired = $auth->isLoginRequired($siteConfig, file_get_contents(__DIR__ . '/../fixtures/nextinpact-login.html'));
@ -177,7 +177,7 @@ class LoginFormAuthenticatorTest extends TestCase
$requestHtmlFunctionClient = new MockHttpClient([$requestHtmlFunctionResponse]);
$authenticatorProvider = new AuthenticatorProvider($requestHtmlFunctionClient);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider, 'Wallabag (Symfony HttpClient/5)');
$loginRequired = $auth->isLoginRequired($siteConfig, file_get_contents(__DIR__ . '/../fixtures/nextinpact-article.html'));
@ -235,7 +235,7 @@ class LoginFormAuthenticatorTest extends TestCase
;
$authenticatorProvider = new AuthenticatorProvider($requestHtmlFunctionClient);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider);
$auth = new LoginFormAuthenticator($browser, $authenticatorProvider, 'Wallabag (Symfony HttpClient/5)');
$res = $auth->login($siteConfig);