Skip to content

[Bug] Sending "lang" via HTTP API ignores country when upper case #22077

@seb303

Description

@seb303

What happened?

When sending the Accept-Language HTTP header field via the "lang" parameter of the HTTP API, the country part is dropped unless it is first converted to lower case.

For example, if the value sent is en-GB,en;q=0.5 or just en-GB then the data stored in log_visit / location_browser_lang is only en.

If we first convert to lower case en-gb,en;q=0.5 or en-gb then it stores en-gb which is more useful information.

What should happen?

It should accept the input en-GB,en;q=0.5 and if it needs to be in lower case internally then the API should convert to lower case rather than discard the country part.

How can this be reproduced?

Here's an example of some API data where the problem occurs:

Array
(
    [idsite] => 3
    [rec] => 1
    [action_name] => Page Title
    [url] => http://page.url/
    [_id] => ab86b7f3bf677d1c
    [apiv] => 1
    [urlref] => http://page.ref/
    [h] => 8
    [m] => 32
    [s] => 44
    [ua] => Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0
    [lang] => en-GB,en;q=0.5
    [token_auth] => xxxxxxxxxxxxxxxxxxxxxxxxx
    [cip] => xxx.xxx.xxx.xxx
    [send_image] => 0
    [res] => 2560x1440
    [devicePixelRatio] => 1.5
    [uid] => 1
    [country] => gb  // in this case we already know the country of this user, but this isn't always present
)

Matomo version

5.0.3

PHP version

8.2.16

Server operating system

Linux

What browsers are you seeing the problem on?

Not applicable (e.g. an API call etc.)

Validations

Metadata

Metadata

Assignees

Labels

BugFor errors / faults / flaws / inconsistencies etc.c: TrackingFor issues related to getting tracking data into Matomo.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions