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

Restrict header values by following specification #15

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

Conversation

amkisko
Copy link

@amkisko amkisko commented Oct 17, 2024

A language tag (which is sometimes referred to as a "locale identifier"). This consists of a 2-3 letter base language tag that indicates a language, optionally followed by additional subtags separated by '-'. The most common extra information is the country or region variant (like 'en-US' or 'fr-CA') or the type of alphabet to use (like 'sr-Latn'). Other variants, like the type of orthography ('de-DE-1996'), are usually not used in the context of this header. Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language

The importance of a value is marked by the suffix ';q=' immediately followed by a value between 0 and 1 included, with up to three decimal digits, the highest value denoting the highest priority. When not present, the default value is 1. Reference: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values

A language tag (which is sometimes referred to as a "locale identifier"). This consists of a 2-3 letter base language tag that indicates a language, optionally followed by additional subtags separated by '-'. The most common extra information is the country or region variant (like 'en-US' or 'fr-CA') or the type of alphabet to use (like 'sr-Latn'). Other variants, like the type of orthography ('de-DE-1996'), are usually not used in the context of this header. Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language

The importance of a value is marked by the suffix ';q=' immediately followed by a value between 0 and 1 included, with up to three decimal digits, the highest value denoting the highest priority. When not present, the default value is 1. Reference: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
@amkisko
Copy link
Author

amkisko commented Oct 17, 2024

Lack of filtering leads to possibility of getting exceptions here:

return available_langtag if available_langtag.match?(/\A#{preferred_tag}/i)
-- due to uncontrolled user input directly passed as regular expression

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.

1 participant