Skip to content

Commit

Permalink
Fix Data URI encoding problem
Browse files Browse the repository at this point in the history
The default encoding of the data URI "data:, ..." is US-ASCII and that causes mojibake when UTF-8 percent encoding is used.
So `request.overrideMimeType("text/plain; charset=UTF-8")` is needed.
  • Loading branch information
MurakamiShinyu committed Mar 11, 2019
1 parent 6cbe824 commit 60fb210
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/adapt/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ adapt.net.ajax = (url, opt_type, opt_method, opt_data, opt_contentType) => {
}
} else if ((/^data:,(<|%3C|%3c)/).test(url)) {
request.overrideMimeType("text/html; charset=UTF-8");
} else if ((/^data:,/).test(url)) {
request.overrideMimeType("text/plain; charset=UTF-8");
}
request.send(null);
}
Expand Down

0 comments on commit 60fb210

Please sign in to comment.