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

Remove duplicated backslash in string escaping #458

Merged
merged 5 commits into from
Feb 9, 2023
Merged

Conversation

cozitive
Copy link
Contributor

@cozitive cozitive commented Feb 7, 2023

What this PR does / why we need it:
At PR #439, I escaped RHT key and value strings to fix issue #437.
When checking EscapeString() function at that time, I thought it should put two backslashes in front of special characters, because JSON.stringify() in JavaScript added two backslashes. For example, the return value of JSON.stringify({"key": "value\n"}) is '{"key":"value\\n"}'.
However, the additional backslash in the example above is just to represent a single backslash in JS string. Valid JSON string uses only a single backslash for control characters.
Since the updated EscapeString() makes invalid JSON strings, it should be reverted.

Which issue(s) this PR fixes:

Fixes #439 and #443

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Merging #458 (4f932c1) into main (7635b73) will increase coverage by 0.09%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #458      +/-   ##
==========================================
+ Coverage   46.47%   46.56%   +0.09%     
==========================================
  Files          70       70              
  Lines        5730     5723       -7     
==========================================
+ Hits         2663     2665       +2     
+ Misses       2773     2764       -9     
  Partials      294      294              
Impacted Files Coverage Δ
pkg/document/crdt/strings.go 81.08% <ø> (+17.44%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

go test -tags bench -benchmem -bench=. ./test/bench -memprofile=mem.prof -cpuprofile=cpu.prof | tee output.txt
mkfifo pipe
tee output.txt < pipe &
go test -tags bench -benchmem -bench=. ./test/bench -memprofile=mem.prof -cpuprofile=cpu.prof > pipe
Copy link
Contributor Author

@cozitive cozitive Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exit status of benchmark test has been ignored, because the exit status of a pipeline is the exit status of the last command (tee) in the pipeline.
To reveal the original exit status, piping command is separated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed description.

Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

go test -tags bench -benchmem -bench=. ./test/bench -memprofile=mem.prof -cpuprofile=cpu.prof | tee output.txt
mkfifo pipe
tee output.txt < pipe &
go test -tags bench -benchmem -bench=. ./test/bench -memprofile=mem.prof -cpuprofile=cpu.prof > pipe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed description.

@hackerwins hackerwins merged commit de20c70 into main Feb 9, 2023
@hackerwins hackerwins deleted the string-escape branch February 9, 2023 03:03
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