8000 Ensure language redirect conditions do not match for too low quality accepted languages by acelaya · Pull Request #2045 · shlinkio/shlink · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ensure language redirect conditions do not match for too low quality accepted languages #2045

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

Merged

Conversation

acelaya
Copy link
Member
@acelaya acelaya commented Mar 7, 2024

Closes #2043

In the initial implementation for language redirect conditions, I decided to let it match for any language present in the Accept-Language header, with the only exception of *.

Unfortunately, due to how browsers decide which languages to send in the Accept-Language header, this resulted in unexpected matching rules when multiple rules are configured for different languages.

For example, if you configure a rule for English and then a rule for Spanish, with an accept language like es-ES,es;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6 the English condition would positively match if it has more priority than the Spanish one, when intuition says that this header should match the Spanish condition.

This PR changes the logic when matching languages, so that a minimum 0.9 quality is required for languages in the Accept-Language header.

In the example above, that would mean that only es-ES and es would end up being evaluated, and the rest would be ignored.

As a side effect, that would mean that someone with the header fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6 would not match the English rule anymore, while it would with previous approach. However, the expected behavior would probably be that no rule matches, and instead redirection falls back to the default long URL, so this is probably correct.

Copy link
codecov bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.34%. Comparing base (97c94f8) to head (8262df1).
Report is 2 commits behind head on develop.

❗ Current head 8262df1 differs from pull request most recent head be8cf56. Consider uploading reports for the commit be8cf56 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #2045   +/-   ##
==========================================
  Coverage      97.34%   97.34%           
  Complexity      1363     1363           
==========================================
  Files            251      251           
  Lines           4825     4825           
==========================================
  Hits            4697     4697           
  Misses           128      128           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acelaya acelaya force-pushed the feature/match-languages-fix branch from 8262df1 to be8cf56 Compare March 7, 2024 22:21
@acelaya acelaya merged commit 31dea8f into shlinkio:develop Mar 7, 2024
@acelaya acelaya deleted the feature/match-languages-fix branch March 7, 2024 22:24
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.

A dynamic rule based on 'en' language takes priority over all other languages
1 participant
0