Last active
May 24, 2016 00:58
-
-
Save ozero/3c8051af2abacdf0a8c361224c52fe63 to your computer and use it in GitHub Desktop.
Inject JS (with multibyte string) by js in a html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<!-- | |
via: | |
"【JavaScript】window.btoa(‘日本語’) する at softelメモ" | |
https://www.softel.co.jp/blogs/tech/archives/4133 | |
--> | |
<script> | |
var script = document.createElement('script'); | |
var sc0 = 'console.log("unescape関数は、パーセントエンコーディングされた文字列をアンエスケープする。一般的なパーセントエンコーディング(%XX)のみでなく、ユニコードパーセントエンコーディング(%uXXXX)も処理する。")' | |
console.log(sc0); | |
var sc0_0 = encodeURIComponent(sc0);//UTF-8でのURI用の%エンコードをする。 | |
console.log(sc0_0); | |
var sc0_1 = unescape(sc0_0);//パーセントエンコーディングされた文字列をアンエスケープ | |
//unescape(encodeURIComponent())された文字列は | |
//元のUTF-8の文字列の各バイトのASCII表現となる。 | |
console.log(sc0_1); | |
var sc0_2 = btoa((sc0_1));//ということで、window.btoaに渡しても大丈夫な形に。 | |
console.log(sc0_2); | |
var sc2 = decodeURIComponent(escape(window.atob(sc0_2))); | |
script.innerHTML = sc2; | |
document.body.appendChild(script); | |
</script> | |
<!-- | |
UWPなwebViewにAssetのJsの中身を流しこむ際にEscapeがアレというのであれば、 | |
「まずencodeURIComponent(sc0);//UTF-8でのURI用の%エンコードをする | |
→unescape(sc0_0);//パーセントエンコーディングされた文字列をアンエスケープ | |
→btoa((sc0_1));//ということで、window.btoaに渡しても大丈夫な形に。」 | |
というC#のコードを通してからInject用JSにくっつけてInvokeScriptAsyncしていくとよいのでは。 | |
"Does C# have an equivalent to JavaScript's encodeURIComponent()? - Stack Overflow" | |
http://goo.gl/c3ZxgM | |
Uri.EscapeDataString()を使えってさ | |
"How can I decode HTML characters in C#? - Stack Overflow" | |
http://goo.gl/9cE72R | |
System.Net.WebUtility.HtmlDecode()でunescapeできるってさ。 | |
"c# - How do I encode and decode a base64 string? - Stack Overflow" | |
http://goo.gl/r1iq4g | |
これのコピペで行けそう? | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment