-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cosmos: Escape invalid characters in the id value #25721
Conversation
Also change the DateTime format to ISO 8601 Fixes #25100
if (propertyValue == null) | ||
{ | ||
builder.Append("null"); | ||
} else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else | |
} | |
else |
var startingIndex = builder.Length; | ||
return builder.Append(stringValue) | ||
.Replace("|", "^|", startingIndex, builder.Length - startingIndex) | ||
.Replace("/", "^2F", startingIndex, builder.Length - startingIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing context, but why do the extra characters need to be escaped (I get that pipe is our custom separator within generated IDs, but the others)? Is there a specific reason for the choice of caret as the escape character?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.resource.id?view=azure-dotnet for the list of invalid characters.
I've tried to URLEncode them, but it seems that the server decodes the values before storing them, so it still fails. Therefore I used the caret as an alternative encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, thanks for the info. A link in a comment could be helpful for future readers.
Also change the
DateTime
format to ISO 8601Fixes #25100