mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: Page.setContent working with unicode strings (#4433)
Fix `page.setContent` with unicode strings that exceeds the range of a 8-bit byte. This patch implements decoding part of the [MDN's solution #4 for the "unicode problem"](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_4_%E2%80%93_escaping_the_string_before_encoding_it). Since we rely on node.js buffer to encode into base64, we don't have troubles with base64 encoding, so it is left as-is. Fixes #4424
This commit is contained in:
committed by
Andrey Lushnikov
parent
3f23bb022e
commit
60249e0bc2
@@ -205,7 +205,7 @@ class DOMWorld {
|
||||
// lifecycle event. @see https://crrev.com/608658
|
||||
await this.evaluate(base64html => {
|
||||
document.open();
|
||||
document.write(atob(base64html));
|
||||
document.write(decodeURIComponent(atob(base64html).split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join('')));
|
||||
document.close();
|
||||
}, Buffer.from(html).toString('base64'));
|
||||
const watcher = new LifecycleWatcher(this._frameManager, this._frame, waitUntil, timeout);
|
||||
|
||||
Reference in New Issue
Block a user