diff --git a/aurweb/config.py b/aurweb/config.py index 637024de..287152d4 100644 --- a/aurweb/config.py +++ b/aurweb/config.py @@ -6,7 +6,7 @@ from typing import Any # Publicly visible version of aurweb. This is used to display # aurweb versioning in the footer and must be maintained. # Todo: Make this dynamic/automated. -AURWEB_VERSION = "v6.0.23" +AURWEB_VERSION = "v6.0.24" _parser = None diff --git a/aurweb/rpc.py b/aurweb/rpc.py index 70d8c2fd..5bc6b80d 100644 --- a/aurweb/rpc.py +++ b/aurweb/rpc.py @@ -332,7 +332,7 @@ class RPC: models.PackageBase ).filter( and_(models.PackageBase.PackagerUID.isnot(None), - models.Package.Name.like(f"%{arg}%")) + models.Package.Name.like(f"{arg}%")) ).order_by(models.Package.Name.asc()).limit(20) return [pkg.Name for pkg in packages] @@ -341,9 +341,10 @@ class RPC: if not args: return [] + arg = args[0] packages = db.query(models.PackageBase.Name).filter( and_(models.PackageBase.PackagerUID.isnot(None), - models.PackageBase.Name.like(f"%{args[0]}%")) + models.PackageBase.Name.like(f"{arg}%")) ).order_by(models.PackageBase.Name.asc()).limit(20) return [pkg.Name for pkg in packages] diff --git a/pyproject.toml b/pyproject.toml index e930a331..7a2f6ca3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ # [tool.poetry] name = "aurweb" -version = "v6.0.23" +version = "v6.0.24" license = "GPL-2.0-only" description = "Source code for the Arch User Repository's website" homepage = "https://aur.archlinux.org" diff --git a/test/test_rpc.py b/test/test_rpc.py index 0d6b2931..2f7f7860 100644 --- a/test/test_rpc.py +++ b/test/test_rpc.py @@ -551,6 +551,14 @@ def test_rpc_suggest_pkgbase(client: TestClient, packages: List[Package]): data = response.json() assert data == [] + # Test that suggestions are only given based on the beginning + # of the keyword string. + params["arg"] = "ther-pkg" + with client as request: + response = request.get("/rpc", params=params) + data = response.json() + assert data == [] + def test_rpc_suggest(client: TestClient, packages: List[Package]): params = {"v": 5, "type": "suggest", "arg": "other"} @@ -573,6 +581,14 @@ def test_rpc_suggest(client: TestClient, packages: List[Package]): data = response.json() assert data == [] + # Test that suggestions are only given based on the beginning + # of the keyword string. + params["arg"] = "ther-pkg" + with client as request: + response = request.get("/rpc", params=params) + data = response.json() + assert data == [] + def mock_config_getint(section: str, key: str): if key == "request_limit":