Skip to content

Conversation

@HeroponRikiBestest
Copy link
Contributor

There is one thing I'd like your advice on, if you have any. I thought i was having encoding issues, as the plus sign was turning into \u002B, but it turns out this specific character is supposed to be treated this way.

dotnet/runtime#35281

Should I

  • Replace the plus sign in any protections with a different character
  • Do a regex replace for \u002B with + on the output
  • Try and use one of the UnsafeRelaxedJsonEscaping options

I'm not sure what's best, since apparently

If you have a JSON string "\\u002B", this search-and-replace will result in the JSON string "\+", which corrupts the JSON payload.

So, doing some kind of workaround doesn't seem ideal.

@HeroponRikiBestest
Copy link
Contributor Author

HeroponRikiBestest commented Nov 8, 2025

Actually, it might not be the responsibility of the json output program to do anything. Looking at "dedicated" json programs, they all seem to display these as plus signs, since that's the way they're supposed to be output to json.

image

@mnadareski
Copy link
Collaborator

With regards to the \u002B issue, I don't see any strong reason why this has to be treated with the sort of security that they're trying to advise. Doing a simple string.Replace on the serialized value to deal with replacement is fine by me.

Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
@HeroponRikiBestest
Copy link
Contributor Author

HeroponRikiBestest commented Nov 10, 2025

I'm not sure either, but considering it's something that seems to explicitly be handled by various different json programs, I'm worried that actually printing a plus might break several programs since it's not intended. I wouldn't know, though.

Dictionary<string, object> node = (Dictionary<string, object>)modifyNodeList[i].Item1;

// Copy the existing KVPs out so they won't be lost
var copyDictionary = new Dictionary<string, object>((Dictionary<string, object>)node[part]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copies the existing KVPs out so they won't be lost

Comment on lines 298 to 299
node[part] = new List<object>();
List<object> modifyNode = (List<object>)node[part];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redefines node that needs to be modified to a list of objects

List<object> modifyNode = (List<object>)node[part];

// Add the "root" protection
modifyNode.Add(nodeProtections);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add the "root" protections

@mnadareski mnadareski merged commit 95a20fb into SabreTools:master Nov 10, 2025
1 check passed
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