Skip to content

fix(entity): reject empty and malformed entity tag ranges (#145, #148) - #237

Open
CyberneticX-Tech wants to merge 1 commit into
hyperium:masterfrom
CyberneticX-Tech:fix/entity-tag-range-decode
Open

fix(entity): reject empty and malformed entity tag ranges (#145, #148)#237
CyberneticX-Tech wants to merge 1 commit into
hyperium:masterfrom
CyberneticX-Tech:fix/entity-tag-range-decode

Conversation

@CyberneticX-Tech

Copy link
Copy Markdown

According to RFC 7232 Sections 3.1 & 3.2 (and RFC 9110 Section 13.1), If-Match and If-None-Match are defined as * or 1#entity-tag (at least one entity tag).

Currently, EntityTagRange::try_from_values succeeds when given an empty iterator or empty values (e.g. IfMatch::decode(&mut [].into_iter()) or &HeaderValue::from_static("")), returning an empty EntityTagRange::Tags(flat) that contains no valid entity tags.

This change:

  1. Validates that values is non-empty before decoding.
  2. Checks that if the value is not *, it contains at least one entity tag and all tags parse successfully via EntityTag::parse.
  3. Adds decode unit tests for both IfMatch and IfNoneMatch covering empty iterators, empty values, whitespace, invalid tag formats, *, and valid tag lists.

Closes #145
Closes #148

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.

IfMatch of empty string doesn't get rejected as expected IfMatch succeeds decode without values given (for example)

1 participant