Skip to content

Conversation

@xuzhg
Copy link
Member

@xuzhg xuzhg commented Oct 23, 2025

Issues

This pull request fixes #xxx.

Description

Briefly describe the changes of this pull request.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

Repository notes

Team members can start a CI build by adding a comment with the text /AzurePipelines run to a PR. A bot may respond indicating that there is no pipeline associated with the pull request. This can be ignored if the build is triggered.

Team members should not trigger a build this way for pull requests coming from forked repositories. They should instead trigger the build manually by setting the "branch" to refs/pull/{prId}/merge where {prId} is the ID of the PR.

@xuzhg
Copy link
Member Author

xuzhg commented Oct 23, 2025

/AzurePipelines run

Copy link
Member

@WanjohiSammy WanjohiSammy left a comment

Choose a reason for hiding this comment

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

Could you add some tests to ensure test coverage

Copy link
Contributor

@habbes habbes left a comment

Choose a reason for hiding this comment

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

Let's not use string.Replace. Base64 strings can be arbitrarily large. In this case we're scanning the entire string twice, and also allocating twice. Bad for CPU and memory. Also, everyone will be paying this cost, even scenarios which are not affected by this issue.

try
{
targetValue = Convert.FromBase64String(text);
targetValue = Convert.FromBase64String(text.Replace('-', '+').Replace('_', '/'));
Copy link
Member

Choose a reason for hiding this comment

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

We can move the logic to JsonSharedUtils as it can be used in OData.Core and OData.Client

@habbes
Copy link
Contributor

habbes commented Oct 28, 2025

Base64Url supports this alphabet (that uses - and _), but it does not seem to support + and /. It returns invalid data. See this sharplab sample

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.

4 participants