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

fix(ops): fallback when FastApiOneByteString is not utf8 #18518

Merged
merged 4 commits into from
Mar 31, 2023

Conversation

littledivy
Copy link
Member

Fixes #18255

Depends on denoland/rusty_v8#1206

Ok(v) => v,
Err(_) => {
unsafe { &mut *fast_api_callback_options }.fallback = true;
return Default::default();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If memory serves, I had to do a separate default return value for pointer returning since there's no Default impl for a void pointer.

}),
StringType::Cow => q!(Vars { var: &ident }, {
let var = ::std::borrow::Cow::Borrowed(unsafe { &*var }.as_str());
let var = ::std::borrow::Cow::Borrowed(
match ::std::str::from_utf8(unsafe { &*var }.as_bytes()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be possible to avoid doing the V8 fallback, and instead just create a String copy conditionally from the bytes?

@littledivy littledivy marked this pull request as ready for review March 31, 2023 14:23
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, let's address the comments after the patch release

@bartlomieju bartlomieju merged commit feab94f into denoland:main Mar 31, 2023
@bartlomieju bartlomieju deleted the fastops_utf8_validate branch March 31, 2023 15:46
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.

TextEncoder.encodeInto may produce wrong result for one-byte non-ASCII characters
3 participants