Prevent loading styles if style position is outside of string

- fixes #1453
This commit is contained in:
Connor Tumbleson 2017-05-04 17:21:39 -04:00 committed by Connor Tumbleson
parent ea16f3ff1d
commit b09dce4050
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75
3 changed files with 19 additions and 0 deletions

View File

@ -131,6 +131,11 @@ public class StringBlock {
if (style == null) {
return ResXmlEncoders.escapeXmlChars(raw);
}
// If the returned style is further in string, than string length. Lets skip it.
if (style[1] > raw.length()) {
return ResXmlEncoders.escapeXmlChars(raw);
}
StringBuilder html = new StringBuilder(raw.length() + 32);
int[] opened = new int[style.length / 3];
int offset = 0, depth = 0;

View File

@ -253,6 +253,11 @@ public class BuildAndDecodeTest {
compareValuesFiles("values-ast/strings.xml");
}
@Test
public void androidOStringTest() throws BrutException, IOException {
compareValuesFiles("values-ast/strings.xml");
}
@Test
public void twoLetterNotHandledAsBcpTest() throws BrutException, IOException {
checkFolderExists("res/values-fr");

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="test1">"Forgot your username or password?\nVisit google.com/accounts/recovery."</string>
<string name="test2">Forgot your username or password?\n.Visit google.com/accounts/recovery</string>
<string name="test3"> (string8) "Forgot your username or password?\nVisit google.com/accounts/recovery."</string>
<string name="test4">Forgot your username or password?\nVisit google.com/accounts/recovery.</string>
<string name="test5">Forgot your username or password?
Visit google.com/accounts/recovery.</string>
</resources>