Skip to content
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

fixed base64 decoding issue #8916

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions source/shared/cpp/ObjectModel/AdaptiveBase64Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ std::string AdaptiveBase64Util::Encode(const std::vector<char>& decodedBase64)
// Format for DataURI is data:[<MediaType>][;base64],data with MediaType and base64 being optional and data is composed of [A-Z a-z 0-9 + /] characters
std::string AdaptiveBase64Util::ExtractDataFromUri(const std::string& dataUri)
{
size_t comaPosition = dataUri.find_last_of(",");
return dataUri.substr(comaPosition + 1);
size_t commaPosition = dataUri.find_last_of(",");
if (commaPosition != std::string::npos)
{
size_t startPosition = std::find_if_not(
dataUri.begin() + commaPosition + 1,
dataUri.end(),
[](char c) { return std::isspace(c); }
) - dataUri.begin();

return dataUri.substr(startPosition);
}

return {};
}
5 changes: 2 additions & 3 deletions source/uwp/SharedRenderer/lib/AdaptiveImageRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,13 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering
svgImageSource.RasterizePixelHeight(size.Height);
svgImageSource.RasterizePixelWidth(size.Width);
}

co_await svgImageSource.SetSourceAsync(stream);
svgImageSource.SetSourceAsync(stream);
}
else
{
co_await wil::resume_foreground(GetDispatcher(strongImageSource));
auto bitmapImage = strongImageSource.as<winrt::BitmapImage>();
co_await bitmapImage.SetSourceAsync(stream);
bitmapImage.SetSourceAsync(stream);
}
}
else
Expand Down
Loading