Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unquote Sec-CH-UA-Platform and Sec-CH-UA-Platform-Version #123

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

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:

@@ -177,5 +177,9 @@ def extract_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.

@@ -4465,10 +4465,10 @@
family: 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