-
Notifications
You must be signed in to change notification settings - Fork 39
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 character escaping issues during config generation #198
Merged
HowardWolosky
merged 2 commits into
microsoft:master
from
HowardWolosky:fixConfigGeneration
Aug 19, 2020
Merged
Fix character escaping issues during config generation #198
HowardWolosky
merged 2 commits into
microsoft:master
from
HowardWolosky:fixConfigGeneration
Aug 19, 2020
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
Many years ago, microsoft#24 attempted to properly escape special characters in a 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. At the time, this clearly 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 use `ConvertTo-Json` directly. Doing that now. One additional update that needed to be done however was to "escape" in `tag` and `notesForCertification` with '//' with '\\'. This isn't _completely_ correct, but not doing so meant that anything after that would be improperly flagged as a comment by `Remove-Comment` and then removed.
/cc: @LanceMcCarthy |
HowardWolosky
added a commit
to HowardWolosky/StoreBroker
that referenced
this pull request
Aug 14, 2020
> This is a re-implementation of microsoft#198 for the v2 branch. Many years ago, microsoft#24 attempted to properly escape special characters in a 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 by `ConvertFrom-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 use `ConvertTo-Json` directly. Doing that now. One additional update that needed to be done however was to replace `//` with `\\` in `tag` and `notesForCertification`. This isn't _completely_ correct, but not doing so meant that anything after that would be improperly flagged as a comment by `Remove-Comment` and then removed. This was found because the same user had a URL in their `notesForCertification` and the closing JSON was getting stripped out incorrectly as soon as it found the `//` in `https://....`.
HowardWolosky
added a commit
to HowardWolosky/StoreBroker
that referenced
this pull request
Aug 14, 2020
> This is a re-implementation of microsoft#198 for the v2 branch. Many years ago, microsoft#24 attempted to properly escape special characters in a 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 by `ConvertFrom-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 use `ConvertTo-Json` directly. Doing that now. One additional update that needed to be done however was to replace `//` with `\\` in `tag` and `notesForCertification`. This isn't _completely_ correct, but not doing so meant that anything after that would be improperly flagged as a comment by `Remove-Comment` and then removed. This was found because the same user had a URL in their `notesForCertification` and the closing JSON was getting stripped out incorrectly as soon as it found the `//` in `https://....`.
HowardWolosky
added a commit
to HowardWolosky/StoreBroker
that referenced
this pull request
Aug 14, 2020
> This is a re-implementation of microsoft#198 for the v2 branch. Many years ago, microsoft#24 attempted to properly escape special characters in a 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 by `ConvertFrom-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 use `ConvertTo-Json` directly. Doing that now. One additional update that needed to be done however was to replace `//` with `\\` in `tag` and `notesForCertification`. This isn't _completely_ correct, but not doing so meant that anything after that would be improperly flagged as a comment by `Remove-Comment` and then removed. This was found because the same user had a URL in their `notesForCertification` and the closing JSON was getting stripped out incorrectly as soon as it found the `//` in `https://....`.
HowardWolosky
added a commit
to HowardWolosky/StoreBroker
that referenced
this pull request
Aug 14, 2020
> This is a re-implementation of microsoft#198 for the v2 branch. Many years ago, microsoft#24 attempted to properly escape special characters in a 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 by `ConvertFrom-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 use `ConvertTo-Json` directly. Doing that now. One additional update that needed to be done however was to replace `//` with `\\` in `tag` and `notesForCertification`. This isn't _completely_ correct, but not doing so meant that anything after that would be improperly flagged as a comment by `Remove-Comment` and then removed. This was found because the same user had a URL in their `notesForCertification` and the closing JSON was getting stripped out incorrectly as soon as it found the `//` in `https://....`.
HowardWolosky
added a commit
that referenced
this pull request
Aug 19, 2020
> This is a re-implementation of #198 for the v2 branch. Many years ago, #24 attempted to properly escape special characters in a 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 by `ConvertFrom-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 use `ConvertTo-Json` directly. Doing that now. One additional update that needed to be done however was to replace `//` with `\\` in `tag` and `notesForCertification`. This isn't _completely_ correct, but not doing so meant that anything after that would be improperly flagged as a comment by `Remove-Comment` and then removed. This was found because the same user had a URL in their `notesForCertification` and the closing JSON was getting stripped out incorrectly as soon as it found the `//` in `https://....`.
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.
Many years ago, #24 attempted to properly escape special characters in a 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://....
.Fixes #197