Skip to content

fix: address potential panics in Result-returning functions (#432)#682

Open
chairulakmal wants to merge 1 commit into
brave:masterfrom
chairulakmal:fix/review-panics-issue-432
Open

fix: address potential panics in Result-returning functions (#432)#682
chairulakmal wants to merge 1 commit into
brave:masterfrom
chairulakmal:fix/review-panics-issue-432

Conversation

@chairulakmal

Copy link
Copy Markdown

Summary

Addresses issue #432 (Case 1): reviews unwrap/expect calls in functions that return a Result.

Converted to error propagation:

  • lists.rsinto_content_blocking() now uses try_for_each + ok_or instead of expect, so a missing raw_line returns Err rather than panicking.
  • resources/resource_storage.rsget_scriptlet_resource() now returns a new InvalidScriptletArgs error instead of unwrapping parse_scriptlet_args(). Malformed scriptlet args (e.g. an unclosed quote) no longer panic. Added a regression test.

Documented remaining safe panics with explanatory comments (abstract_network.rs, url_parser/parser.rs, regex_manager.rs, blocker.rs, cosmetic_filter_cache_builder.rs).

Does not overlap with #662, which covers content_blocking.rs.

Tests

cargo test --lib and cargo test --lib --features content-blocking pass; cargo clippy --features content-blocking -- -D warnings is clean.

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