-
Notifications
You must be signed in to change notification settings - Fork 782
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
Enhancements for feature macros #195
Open
dominickpastore
wants to merge
19
commits into
zserge:master
Choose a base branch
from
dominickpastore:feature-macros
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ensure primitives are "true", "false", "null", or an RFC 8259 compliant number. (Still need to add test cases.)
String parsing previously did not differ between strict and non-strict modes, but was not fully compliant with RFC 8259. RFC 8259 requires that control characters (code points < 0x20) be escaped. This is now enforced in strict mode. In addition, non-strict mode now does *no* validations on string contents, much like primitives in non-strict mode.
dominickpastore
force-pushed
the
feature-macros
branch
from
May 28, 2020 06:11
cbbb30d
to
bb7fa41
Compare
dominickpastore
force-pushed
the
feature-macros
branch
from
June 1, 2020 18:03
bb7fa41
to
ee19c93
Compare
Apologize for the history rewriting. Rebased onto the latest commits from PR #194. |
Parent links and strict parsing are now the default behavior. New macros JSMN_LOW_MEMORY and JSMN_NON_STRICT disable these behaviors. JSMN_PARENT_LINKS still exists, but is defined by default unless JSMN_LOW_MEMORY is defined. JSMN_STRICT no longer exists. Instead, we have three new macros: JSMN_PERMISSIVE_PRIMITIVES - Relaxes validation of primitives. Any characters except whitespace and {}[],:" become allowed. (Normally, only "true", "false", "null", and RFC 8259 numbers are permitted.) JSMN_PERMISSIVE_STRINGS - Relaxes validation of strings. Any characters allowed. (Normally, control characters (<0x20) and invalid escape sequences are foridden.) JSMN_PRIMITIVE_KEYS - Allows primitives to be used as object keys. These can be defined individually, or defining JSMN_NON_STRICT will cause all to be defined. Tests have not yet been adapted for these changes.
dominickpastore
force-pushed
the
feature-macros
branch
from
June 5, 2020 14:23
ee19c93
to
fbcf781
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does two things:
Details
More granular macros
This PR builds on the changes from PR #194. With PR #194, there are three specific ways in which non-strict mode diverges from RFC 8259:
{}[],:"
).\x01
-\x1F
) and invalid escape sequencesSome projects using jsmn might want some of these features, but not all. For example, a project might want to enable (1) to improve performance or shrink code size, but leave (3) disabled to help catch bugs.
For this purpose, this PR creates three new macros:
JSMN_PERMISSIVE_PRIMITIVES
for (1),JSMN_PERMISSIVE_STRINGS
for (2), andJSMN_PRIMITIVE_KEYS
for (3). These can be defined individually, or definingJSMN_NON_STRICT
will cause all to be defined.Enable strict mode and parent links by default
With this PR, strict RFC 8259 compliance and parent links become the default behavior. New macros
JSMN_LOW_MEMORY
andJSMN_NON_STRICT
disable these behaviors.JSMN_PARENT_LINKS
still exists, but is defined by default unlessJSMN_LOW_MEMORY
is defined.JSMN_NON_STRICT
replacesJSMN_STRICT
. When defined, all non-strict features are enabled.