diff options
author | Christian Schneider | 2020-06-15 16:17:36 +0200 |
---|---|---|
committer | Christian Schneider | 2020-06-15 16:17:36 +0200 |
commit | 77cb6c93b8822423b5be5113a1006c93958d26af (patch) | |
tree | 5cc0531b8f5ca1d2edc54672a17f856c13a30c7a | |
parent | 41e97ea93fa8769dcd3c0256837633be6435b4f9 (diff) | |
download | itools-77cb6c93b8822423b5be5113a1006c93958d26af.tar.gz itools-77cb6c93b8822423b5be5113a1006c93958d26af.tar.bz2 itools-77cb6c93b8822423b5be5113a1006c93958d26af.zip |
Only use T_defaultlang() for search.ch subrequests which uses language overrides in URLs, external requests should ask for current language seen by user
-rw-r--r-- | it_url.class | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/it_url.class b/it_url.class index 6e415ba..6608ee4 100644 --- a/it_url.class +++ b/it_url.class @@ -168,13 +168,14 @@ function parse_http_header($header) static function _default_headers($url, $p) { - if ((!it::is_devel() || EDC('subreqcheck')) && $p['url'] && !$p['headers']['Accept-Language'] && T_lang() != T_defaultlang() && it::match('search\.ch/', $p['url']) && !it::match('\blogin\.|banner\.html|machines\.txt|mbtiles\.php|/itjs/|/images/|\.(de|fr|en|it)(\.js|\.html|\.txt|\.php|\.ics|\.pdf|\.json|\.csv|\.gif|\.jpg|\.png)', $p['url'])) + $search_subrequest = it::match('search\.ch/', $p['url']); + if ((!it::is_devel() || EDC('subreqcheck')) && $p['url'] && !$p['headers']['Accept-Language'] && T_lang() != T_defaultlang() && $search_subrequest && !it::match('\blogin\.|banner\.html|machines\.txt|mbtiles\.php|/itjs/|/images/|\.(de|fr|en|it)(\.js|\.html|\.txt|\.php|\.ics|\.pdf|\.json|\.csv|\.gif|\.jpg|\.png)', $p['url'])) it::error(['title' => "Subrequest without language override", 'body' => [ $p ]]); $headers = [ 'Host' => $url->realhostname . $url->explicitport, 'User-Agent' => "Mozilla/5.0 (compatible; ITools; Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582)", - 'Accept-Language' => $p['headers']['Accept-Language'] ?: T_defaultlang(), # can prevent loading of it_text + 'Accept-Language' => $p['headers']['Accept-Language'] ?: ($search_subrequest ? T_defaultlang() : T_lang()), # can prevent loading of it_text 'Referer' => it::match('([-\w]+\.\w+)$', $url->hostname) == it::match('([-\w]+\.\w+)$', $_SERVER['HTTP_HOST']) ? it_url::absolute(U($_GET)) : null, 'X-Ultra-Https' => $_SERVER['HTTPS'], ]; |