Improve injector validation and URL encoding in struct.lua#43
Merged
Conversation
- join: filter out "null" sentinel strings to match TS null filtering - Injection:setval: return delprop/setprop result instead of always self.parent, fixing transform_RENAME ancestor node detection - escurl: match encodeURIComponent by preserving !'()* characters - transform_COPY: use checkPlacement for proper error reporting - transform_EACH: use checkPlacement with T_list parent type check and injectorArgs for argument type validation - transform_PACK: use checkPlacement with T_map parent type check and injectorArgs for argument type validation - Add forward declarations for checkPlacement and injectorArgs https://claude.ai/code/session_01Jzi2moac4BhHEpNjwV2HBe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the struct.lua module with improved validation for data transformation injectors and fixes URL encoding behavior to better match standard encodeURIComponent semantics.
Key Changes
Injector Validation Framework: Introduced
checkPlacement()andinjectorArgs()helper functions to validate that transformers ($COPY,$EACH,$PACK) are used in correct modes and with proper parent types. These functions now provide consistent error reporting through the injector's error collection.URL Encoding Enhancement: Updated
escurl()function to preserve additional characters (! ' ( ) *) that should not be encoded according to encodeURIComponent behavior, improving compatibility with standard URL encoding.Null Value Handling: Fixed
join()function to properly skip null values (S_null) in addition to empty string markers (S_MT) when building string arrays.Property Mutation Return Values: Modified
setval()method in the Injection class to properly capture and return the parent object returned bysetprop()anddelprop()operations, ensuring correct parent reference tracking after mutations.Argument Extraction: Refactored
$EACHand$PACKtransformers to use the newinjectorArgs()function for type-safe argument extraction with proper error handling and reporting.Implementation Details
checkPlacementandinjectorArgsto support their use throughout the module'$EACH: ...')https://claude.ai/code/session_01Jzi2moac4BhHEpNjwV2HBe