Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

fix(body-digest): fix the digest may be duplicated when it is at index 0#23

Open
tklai wants to merge 2 commits intoliamdennehy:masterfrom
tklai:duplicated-digest-fix
Open

fix(body-digest): fix the digest may be duplicated when it is at index 0#23
tklai wants to merge 2 commits intoliamdennehy:masterfrom
tklai:duplicated-digest-fix

Conversation

@tklai
Copy link

@tklai tklai commented Jul 28, 2021

When the digest is at index 0, array_search() will return 0 but the if statement will become !0, which indicates the digest is not found in the $headerList and the program appends it to the array.

Before

[
  0 => "digest"
  1 => "(request-target)"
]

After

[
  0 => "digest"
  1 => "(request-target)"
  2 => "digest"
]

This change will improve the checking and only append digest when array_search() returns false.

EDIT: Added the missing 'if' before 'statement'

tklai added 2 commits July 28, 2021 13:00
When the `digest` is at index 0, `array_search()` will return 0 but the statement will become `!0`, which indicates the `digest` is not found in the `$headerList`.
This change will improve the checking and only append `digest` when `array_search() returns `false`.
Signed-off-by: TK Lai <iam@tklai.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant