fix: check string encoding before creating value (#13818)
This commit is contained in:
parent
a880e0222f
commit
3ad6abc5cc
1 changed files with 7 additions and 3 deletions
|
@ -167,14 +167,18 @@ int ResponseWriter::Initialize(const net::CompletionCallback& callback) {
|
||||||
int ResponseWriter::Write(net::IOBuffer* buffer,
|
int ResponseWriter::Write(net::IOBuffer* buffer,
|
||||||
int num_bytes,
|
int num_bytes,
|
||||||
const net::CompletionCallback& callback) {
|
const net::CompletionCallback& callback) {
|
||||||
auto* id = new base::Value(stream_id_);
|
std::string chunk = std::string(buffer->data(), num_bytes);
|
||||||
base::Value* chunk = new base::Value(std::string(buffer->data(), num_bytes));
|
if (!base::IsStringUTF8(chunk))
|
||||||
|
return num_bytes;
|
||||||
|
|
||||||
|
base::Value* id = new base::Value(stream_id_);
|
||||||
|
base::Value* chunk_value = new base::Value(chunk);
|
||||||
|
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
base::BindOnce(&InspectableWebContentsImpl::CallClientFunction, bindings_,
|
base::BindOnce(&InspectableWebContentsImpl::CallClientFunction, bindings_,
|
||||||
"DevToolsAPI.streamWrite", base::Owned(id),
|
"DevToolsAPI.streamWrite", base::Owned(id),
|
||||||
base::Owned(chunk), nullptr));
|
base::Owned(chunk_value), nullptr));
|
||||||
return num_bytes;
|
return num_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue