Skip to content

Commit

Permalink
lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
sadym-chromium committed Dec 16, 2024
1 parent 645ceee commit bc1e1df
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,25 @@ def is_path_correct(script: Text, src: Text) -> bool:

def is_query_string_correct(script: Text, src: Text,
allowed_query_string_params: Dict[str, List[str]]) -> bool:
"""
Checks if the query string in a script tag's `src` is valid.
Specifically, it verifies that the query string parameters and their
values are among those allowed for the given script. It handles vendor
prefixes (parameters or values containing a colon) by allowing them
unconditionally.
:param script: the name of the script (e.g., "testharness.js"). Used
to verify is the given `src` is related to the
script.
:param src: the full `src` attribute value from the script tag.
:param allowed_query_string_params: A dictionary where keys are
allowed parameter names and
values are lists of allowed
values for each parameter.
:return: if the query string does not contain any not-allowed
params.
"""
if not ("%s" % src).startswith("/resources/%s?" % script):
# The src is not related to the script.
return True
Expand Down

0 comments on commit bc1e1df

Please sign in to comment.