Skip to content

Conversation

@cbeckr
Copy link

@cbeckr cbeckr commented Jun 25, 2024

Since clients provide these headers in quoted form, the related logic is off in real-world use.

References:

def extract_model
return if headers['Sec-CH-UA-Model'].nil? || headers['Sec-CH-UA-Model'] == ''

headers['Sec-CH-UA-Model']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into this issue too. I believe we also need to unquote 'Sec-CH-UA-Model', which is also wrapped, at least on MacOS Chrome.

headers:
Sec-CH-UA: '" Not A;Brand";v="99.0.0.0", "Chromium";v="98.0.4758.109", "Gener8";v="98.0.4758.109"'
Sec-CH-UA-Platform: "Windows"
Sec-CH-UA-Platform: '"Windows"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, these kind of changes will be overwritten on the first fixtures sync from the upstream: fixtures are not updated manually. There is bundle exec rake update_fixtures specifically for that:

device_detector/Rakefile

Lines 69 to 88 in e68ee76

desc 'update fixtures from piwik project'
task :update_fixtures do
top = File.expand_path(__dir__)
get_latest_piwik_checkout
fixture_mappings = [
{ target_path: "#{top}/spec/fixtures/detector", source_path: 'Tests/fixtures/*.yml' },
{ target_path: "#{top}/spec/fixtures/client",
source_path: 'Tests/Parser/Client/fixtures/*.yml' },
{ target_path: "#{top}/spec/fixtures/parser", source_path: 'Tests/Parser/fixtures/*.yml' },
{ target_path: "#{top}/spec/fixtures/device",
source_path: 'Tests/Parser/Device/fixtures/*.yml' }
]
fixture_mappings.each do |mapping|
source_path = mapping.fetch(:source_path)
target_path = mapping.fetch(:target_path)
system "cp -R #{PIWIK_CHECKOUT_LOCATION}/#{source_path} #{target_path}"
end
end

I would suggest to add a dedicated test for the unquote functionality outside of the existing fixtures. Some examples can be found in here: https://github.com/podigee/device_detector/tree/develop/spec/device_detector

@liviuconcioiu
Copy link

Hi everyone! If you think there's something that should be changed upstream, it will be much better to open an issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants