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 reading strings that contain quotes or open/closed brackets #8

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

Neradoc
Copy link
Contributor

@Neradoc Neradoc commented Mar 14, 2025

The parsing code did not properly ignore escaped quotes inside strings, which means that a string containing something like a serialized object would be potentially read wrong by switching in and out of being "in string". next_value also did not ignore {and [ that are inside a string, interpreting them as a "child" list or object.

This would manifest by returning a TransientObject from a string, raising KeyError, EOF or a JSON parsing error, or falling into an infinite loop.

This PR ignores the special meaning of the first character after a backslash inside a string (outside a string it would not be valid json anyway), and rearranges the parsing code to switch more consistently between in-string and not in-string.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you!

@tannewt tannewt merged commit d6d0ace into adafruit:main Mar 17, 2025
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 3, 2025
Updating https://github.com/adafruit/Adafruit_CircuitPython_INA228 to 1.0.1 from 1.0.0:
  > Update adafruit_ina228.py

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1305 to 1.4.0 from 1.3.21:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1305#16 from mikeysklar/ssd1305-white-module-col-offset

Updating https://github.com/adafruit/Adafruit_CircuitPython_TLV320 to 1.0.0 from 51c14aa:
  < Update README.rst

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 2.3.0 from 2.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#70 from tannewt/cmap03

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.2.4 from 3.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#219 from FoamyGuy/use_ruff

Updating https://github.com/adafruit/Adafruit_CircuitPython_JSON_Stream to 0.9.0 from 0.8.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_JSON_Stream#9 from Neradoc/iterator-on-objects
  > Merge pull request adafruit/Adafruit_CircuitPython_JSON_Stream#8 from Neradoc/fix-string-in-string

Updating https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Descriptors to 0.2.1 from 0.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_USB_Host_Descriptors#4 from FoamyGuy/two_mice_example
  > Merge pull request adafruit/Adafruit_CircuitPython_USB_Host_Descriptors#3 from FoamyGuy/find_mouse_helper

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_TLV320
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