Fix character escaping issues during config generation #199
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.
Many years ago, #24 attempted to properly escape special characters in string by creating its own
Get-EscapedJsonValue
function, but that only escaped\
,\t
,\r
,\n
. That doesn't cover all the possible characters needing to be encoded though.A user had a
<
character (which was properly JSON-escaped as\u003c
), but that didn't get escaped by this logic, and thus caused an issue when trying to get decoded byConvertFrom-Json
later on.Back then,
Get-EscapedJsonValue
must have seemed like a good idea, but looking back at this code with more experience, it's not clear to me why I didn't just useConvertTo-Json
directly. Doing that now.One additional update that needed to be done however was to replace
//
with\\
intag
andnotesForCertification
. This isn't completely correct, but not doing so meant that anything after that would be improperly flagged as a comment byRemove-Comment
and then removed. This was found because the same user had a URL in theirnotesForCertification
and the closing JSON was getting stripped out incorrectly as soon as it found the//
inhttps://....
.