fix: refuse fixed p-register hooks on static methods and harden small spots in the patches #120

Closed
midas wants to merge 0 commits from review/85-hook-robustness into dev
Owner

Part of #105, fixes #85 and the non-Videoland points of #100.

  • #85: parameterRegister(method, index, type, ...) derives a parameter's pN from the signature (static or not) and checks its type; requireInstanceMethod(...) throws when a hook uses p0 as this on a static method. Used at every fixed-pN hook in Edition, Kubus, Videoland Hide ads and the DPG video SDK. Edition Hide ads' "p1 is the Context" comment corrected.
  • #100: Edition Markdown requires exactly one addShareAction returning V; isReleaseBuild matched by FieldReference.name; MiniJson: BOM as , lone - rejected, bad \u escape -> PatchException, MiniJsonTest; Firebase patch KDoc; Kubus gelderlander* vals renamed to kubus*, merged dependsOn, featureFlagOverridePatch gets compatibleWith, redundant toList() removed, no obfuscated names in comments.

Verified: buildAndroid incl. contract check and MiniJsonTest; list-patches --with-packages --with-versions identical to origin/dev; Applied identical to origin/dev on de Volkskrant 7.53.1 (13), Trouw 7.52.0 (13), Tubantia 9.22.0, De Gelderlander 9.21.1 and AD 9.21.1 (15 each). No device test.

🤖 Generated with Claude Code

Part of #105, fixes #85 and the non-Videoland points of #100. - #85: `parameterRegister(method, index, type, ...)` derives a parameter's `pN` from the signature (static or not) and checks its type; `requireInstanceMethod(...)` throws when a hook uses `p0` as `this` on a static method. Used at every fixed-`pN` hook in Edition, Kubus, Videoland Hide ads and the DPG video SDK. Edition Hide ads' "p1 is the Context" comment corrected. - #100: Edition Markdown requires exactly one `addShareAction` returning `V`; `isReleaseBuild` matched by `FieldReference.name`; MiniJson: BOM as ``, lone `-` rejected, bad `\u` escape -> PatchException, `MiniJsonTest`; Firebase patch KDoc; Kubus `gelderlander*` vals renamed to `kubus*`, merged `dependsOn`, `featureFlagOverridePatch` gets `compatibleWith`, redundant `toList()` removed, no obfuscated names in comments. Verified: `buildAndroid` incl. contract check and MiniJsonTest; `list-patches --with-packages --with-versions` identical to origin/dev; Applied identical to origin/dev on de Volkskrant 7.53.1 (13), Trouw 7.52.0 (13), Tubantia 9.22.0, De Gelderlander 9.21.1 and AD 9.21.1 (15 each). No device test. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Hooks on obfuscated or R8-processed methods assumed fixed p1/p2 registers,
which is only right for an instance method: if R8 makes the method static,
every parameter register shifts down by one and the hook silently reads or
overwrites the wrong argument.

Add parameterRegister (derives the pN of a parameter from the signature and
checks its type, so a changed signature fails at patch time with a
PatchException, and a static method simply yields the right register) and
requireInstanceMethod (for hooks that use p0 as this) next to
requireLocalRegisters, and use them at every fixed-register hook in the
Edition, Kubus and DPG video SDK patches. The Edition Hide ads comment that
called p1 "the Context parameter in both methods" now matches the three
methods it covers.

Edition Copy article as Markdown now also throws unless there is exactly one
addShareAction call and it returns void, since the hook is inserted right
after it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Register derivation (#85 follow-up for the code that was merged meanwhile):
  Videoland Hide ads, Kubus Disable tracking and the Kubus Markdown click hook
  now derive their parameter registers with parameterRegister /
  requireInstanceMethod instead of fixed p1.
- Edition Disable tracking finds the isReleaseBuild field by FieldReference.name
  instead of toString().contains.
- MiniJson: the BOM is a "" escape, a lone "-" is rejected, a bad \u escape
  throws PatchException instead of NumberFormatException, and the duplicate
  Number branch of write is merged. Unit tests in patches/src/test.
- KDoc for the Firebase In-App Messaging patch.
- Kubus: the gelderlander* patch vals in kubus packages are named kubus*, the
  split dependsOn calls are merged, featureFlagOverridePatch is compatibleWith
  the Kubus apps, redundant toList() calls are gone (also in Edition), and
  comments no longer name obfuscated classes of one build.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix: write MiniJson's BOM as an escape instead of a literal character
All checks were successful
CI / Build (pull_request) Successful in 4m5s
5adc771082
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged into dev as bf097f9 (merged locally together with other review PRs, so Forgejo didn't mark it merged).

Merged into dev as bf097f9 (merged locally together with other review PRs, so Forgejo didn't mark it merged).
midas closed this pull request 2026-10-17 21:03:31 +02:00
All checks were successful
CI / Build (pull_request) Successful in 4m5s
Required
Details

Pull request closed

Sign in to join this conversation.
No description provided.