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

Proper string escaping and arena deepcopy #2

Merged

Conversation

klondikedragon
Copy link

  • Merged the fix to string escape during serialization from escapeString compatibility with encoding/json valyala/fastjson#87 (thanks @barkyq!)
  • Added unit tests to ensure string escape exactly matches standard library behavior (no bugs found)
  • Added Arena.DeepCopyValue, which can be used to change the lifecycle of a Value (e.g., to extend the lifetime of a Value returned by Scanner)
  • Added Arena.NewNumberStringBytes function - creates a new number from the arena storing the string bytes data inside the arena - can be useful by those already managing values and arena scope carefully to store other related string data
  • Added Arena.AllocateStringFromStringBytes function to allocate and copy arbitrary string bytes data into the arena
  • Clarified instructions for ArenaPool.Put to make sure callers get the benefit that they expect
  • Made concurrent tests for Arena more rigorous and refactored into a generic test driver
  • Small fixups to existing unit tests

barkyq and others added 10 commits January 15, 2023 20:43
and `encoding/json` from standard library
it is in range 0x23-0x5B see page 8 of:
https://www.rfc-editor.org/rfc/rfc8259.html

this should not be a problem though, if the unescape is applied to
properly escaped json data
Tests for string escape conformance with standard lib
Useful when needing to get the original representation of the number.
This is needed when wanting to make an exact copy of a Value.
Arena.DeepCopyValue is useful to change the lifecycle of a Value (e.g.,
to extend the lifetime of a Value returned by Scanner)

Also add:
* Arena.NewNumberStringBytes - creates a new number from the arena
  storing the string bytes data inside the arena
* Arena.AllocateStringFromStringBytes - utility function to allocate and
  copy arbitrary string bytes data into the arena

Also clarified instructions for ArenaPool.Put to make sure callers get
the benefit that they expect.
@paralin
Copy link
Member

paralin commented Sep 1, 2024

Thanks, this looks great! I'll review and merge tomorrow.

@paralin
Copy link
Member

paralin commented Sep 8, 2024

Looks good, thanks.

@paralin paralin merged commit e538c2b into aperturerobotics:master Sep 8, 2024
7 checks passed
@klondikedragon klondikedragon deleted the proper-escaping-and-deepcopy branch November 7, 2024 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants