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

html元素中包含emoji表情时,生成报错 #35

Closed
lujihong opened this issue Jul 14, 2023 · 8 comments
Closed

html元素中包含emoji表情时,生成报错 #35

lujihong opened this issue Jul 14, 2023 · 8 comments
Labels

Comments

@lujihong
Copy link

lujihong commented Jul 14, 2023

Steps To Reproduce

html元素中包含emoji表情时,生成报错:String contained illegal UTF-16 sequence.

IOS 16.5.1 微信 8.0.39

@lujihong
Copy link
Author

修改以下代码就没问题了:
function de(e) {
const t = new XMLSerializer().serializeToString(e)
.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/ug, ""); //方法一:去掉\uD800-\uDFFF
//.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/ug, ""); //方法二:注释掉全部
return data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)};
}

@qq15725
Copy link
Owner

qq15725 commented Jul 29, 2023

这段代码是过滤掉 xml 中 null 控制符的,估计是误伤两个 unicode 组成的 emoji 了,可以提供下异常的 emoji

@lujihong
Copy link
Author

😊😘 我随便测试了几个emoji都有问题

@qq15725
Copy link
Owner

qq15725 commented Jul 31, 2023

image

https://modern-screenshot.vercel.app/

这两个 emoji 我浏览器是没问题,看是环境问题还是其他 emoji ,最好是把整段有问题的提供下

@qq15725
Copy link
Owner

qq15725 commented Jul 31, 2023

v4.4.27 支持了只启用部分特性

domToPng({
  features: {
    // 不启用移除控制符
    removeControlCharacter: false,
  }
})

@qq15725 qq15725 closed this as completed Jul 31, 2023
@lujihong
Copy link
Author

我在MAC 端测试没问题,在安卓端测试也没问题,在IOS 16.5.1 微信8.0.39端测试就不行

@jeremiecarlson
Copy link

I have the same issue - iOS only - no issue on desktop Safari
Using domToBlob in my use case.
Setting removeControlCharacter to true/false makes no difference to the error

@jeremiecarlson
Copy link

jeremiecarlson commented Dec 13, 2023

Using the vercel demo app you can reproduce:
Running iPhone 15 simulator on iOS 17.2

Screenshot 2023-12-13 at 1 30 56 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants