Validate Android TV package names#587
Conversation
Greptile SummaryThis PR adds a regex-based validation of Android package names in the
Confidence Score: 4/5Safe to merge — the change is a small, additive guard with no effect on existing valid inputs. The regex correctly enforces Android application ID rules, closing the path-traversal and single-segment gaps. The only minor gap is that uppercase letters are permitted in the regex, which could allow IDs that the Play Store and Android tooling would reject. No files require special attention; both changed files are straightforward and self-contained. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build / ship called] --> B[buildPlan]
B --> C[requirePackageName]
C --> D{packageName truthy?}
D -- No --> E[throw: tv-androidtv requires packageName]
D -- Yes --> F{matches ANDROID_PACKAGE_NAME_RE?}
F -- No --> G[throw: must be valid Android application ID]
F -- Yes --> H[return trimmed packageName]
H --> I[artifactPath / maybeValidateManifest]
I --> J[write plan JSON / upload to Play Console]
Reviews (1): Last reviewed commit: "Validate Android TV package names" | Re-trigger Greptile |
| } | ||
|
|
||
| const PLAN_FILE = 'androidtv-package-plan.json'; | ||
| const ANDROID_PACKAGE_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_]*(?:\.[a-zA-Z][a-zA-Z0-9_]*)+$/; |
There was a problem hiding this comment.
The regex allows uppercase letters in every segment position (
[a-zA-Z]), so names like Com.Acme.App or com.Acme.TV pass validation. Android application IDs are required to be all-lowercase by the Play Store and Android tooling (aapt, bundletool), and a mixed-case ID would cause a mismatch if the same string is compared case-sensitively against the manifest or Gradle config. Restricting the character class to [a-z] keeps the guard aligned with the official Android docs and Play Store requirements.
| const ANDROID_PACKAGE_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_]*(?:\.[a-zA-Z][a-zA-Z0-9_]*)+$/; | |
| const ANDROID_PACKAGE_NAME_RE = /^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/; |
Fixes #586.
Changes:
Validation: