forked from Boria138/PortProtonQt
fix: reject candidate if normalized name equals "game"
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
@@ -211,14 +211,28 @@ def normalize_name(s):
|
|||||||
|
|
||||||
def is_valid_candidate(candidate):
|
def is_valid_candidate(candidate):
|
||||||
"""
|
"""
|
||||||
Checks if a candidate contains forbidden substrings:
|
Determines whether a given candidate string is valid for use as a game name.
|
||||||
- win32
|
|
||||||
- win64
|
The function performs the following checks:
|
||||||
- gamelauncher
|
1. Normalizes the candidate using `normalize_name()`.
|
||||||
Additionally checks the string without spaces.
|
2. Rejects the candidate if the normalized name is exactly "game"
|
||||||
Returns True if the candidate is valid, otherwise False.
|
(to avoid overly generic names).
|
||||||
|
3. Removes spaces and checks for forbidden substrings:
|
||||||
|
- "win32"
|
||||||
|
- "win64"
|
||||||
|
- "gamelauncher"
|
||||||
|
These are checked in the space-free version of the string.
|
||||||
|
4. Returns True only if none of the forbidden conditions are met.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
candidate (str): The candidate string to validate.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the candidate is valid, False otherwise.
|
||||||
"""
|
"""
|
||||||
normalized_candidate = normalize_name(candidate)
|
normalized_candidate = normalize_name(candidate)
|
||||||
|
if normalized_candidate == "game":
|
||||||
|
return False
|
||||||
normalized_no_space = normalized_candidate.replace(" ", "")
|
normalized_no_space = normalized_candidate.replace(" ", "")
|
||||||
forbidden = ["win32", "win64", "gamelauncher"]
|
forbidden = ["win32", "win64", "gamelauncher"]
|
||||||
for token in forbidden:
|
for token in forbidden:
|
||||||
|
Reference in New Issue
Block a user