Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of quoted cookie values #288

Merged
merged 1 commit into from
Jan 4, 2021
Merged

Conversation

theawless
Copy link
Contributor

@theawless theawless commented Jan 3, 2021

I hit this bug in my project where the cookie value was "" - just two quote characters.
On checking the code, I figured that this bug might exist for all quoted cookie values.

The test case I had written for quoted cookie values was failing with this error:

failures:
---- cookies::cookie::tests::parse_simple::_r_foo_bar_ stdout ----
thread 'cookies::cookie::tests::parse_simple::_r_foo_bar_' panicked at 'assertion failed: `(left == right)`
  left: `"ba"`,
 right: `"bar"`', src\cookies\cookie.rs:310:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Previously one extra character was getting stripped from the end.
This commit fixes the index while stripping the end quote.

Previously one extra character was getting stripped from the end.
This commit fixes the index while stripping the end quote.
@codecov
Copy link

codecov bot commented Jan 3, 2021

Codecov Report

Merging #288 (6fb0c95) into master (18ee975) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #288      +/-   ##
==========================================
+ Coverage   72.79%   72.83%   +0.04%     
==========================================
  Files          51       51              
  Lines        2727     2728       +1     
==========================================
+ Hits         1985     1987       +2     
+ Misses        742      741       -1     
Impacted Files Coverage Δ
src/cookies/cookie.rs 87.20% <100.00%> (+0.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18ee975...6fb0c95. Read the comment docs.

@theawless theawless marked this pull request as ready for review January 3, 2021 22:09
@theawless theawless requested a review from sagebind as a code owner January 3, 2021 22:09
@sagebind
Copy link
Owner

sagebind commented Jan 4, 2021

Thanks for finding and fixing this bug, this could be pretty annoying to run into. I see you also updated the unit tests too! ❤️

@sagebind sagebind merged commit 0c38545 into sagebind:master Jan 4, 2021
@sagebind
Copy link
Owner

sagebind commented Jan 11, 2021

This is now available in the 1.0.3 release! Sorry about the delay, we were waiting for a third-party dependency to fix a compile error introduced by a new syn release published.

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.

2 participants