Created
June 16, 2015 06:59
-
-
Save perillamint/3a97381a524653d68c23 to your computer and use it in GitHub Desktop.
Exploit of character breaking bug in https://github.com/EBvi/dev-matrix/blob/master/dev-test.md
This file contains 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
// NOTE: This example uses tengwar glyph in Unicode SMP. | |
// To properly render all glyph, you need font which support | |
// U+16080-160FF range. | |
// | |
// Here is modified FreeMonoTengwar font for that purpose. | |
// http://galadriel.gentoo.moe/tengwar-SMP/ | |
class smptest | |
{ | |
public static void main(String args[]) | |
{ | |
// Tengwar in SMP. WARN: TENTATIVELY ALLOCATED CODEPOINT | |
// This string is 32 * 2 + 1 byte in UTF-16 | |
char[] arr = "πππ’πππ π₯π πππ’πππ π₯π".toCharArray(); | |
StringBuffer sb = new StringBuffer(); | |
int size = 0; | |
for (char c : arr) | |
{ | |
size += (c > 255) ? 2 : 1; //Is it 2byte? | |
sb.append(c); | |
// It will break Tehtar U+160C4 | |
if(size >= 63) | |
break; | |
} | |
System.out.println(sb); | |
//Output: πππ’πππ π₯π πππ’πππ π₯? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment