Skip to content

Return error instead of panicking on malformed scriptlet args - #745

Open
starlinker28-spec wants to merge 1 commit into
brave:masterfrom
starlinker28-spec:fix-scriptlet-args-panic
Open

starlinker28-spec wants to merge 1 commit into
brave:masterfrom
starlinker28-spec:fix-scriptlet-args-panic

Conversation

@starlinker28-spec

Copy link
Copy Markdown

Part of #432.

get_scriptlet_resource called .unwrap() on parse_scriptlet_args, which returns None for malformed input such as an unclosed quote (e.g. greet, 'unclosed). Since get_scriptlet_resources is public, any caller passing malformed args could trigger a panic.

This now returns a new ScriptletResourceError::MalformedScriptletArgs error instead. get_scriptlet_resources already skips scriptlets that return an error, so malformed input is ignored rather than crashing.

Added a test case to get_patched_scriptlets covering this; it panics without the fix and passes with it.

Note: this adds a variant to the public ScriptletResourceError enum.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant