Loading graphics/java/android/graphics/FontListParser.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -155,7 +155,7 @@ public class FontListParser { @VisibleForTesting @VisibleForTesting public static int makeTag(char c1, char c2, char c3, char c4) { public static int makeTag(char c1, char c2, char c3, char c4) { return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4; return (c1 << 24) | (c2 << 16) | (c3 << 8) | c4; } } private static boolean isSpacer(char c) { private static boolean isSpacer(char c) { Loading Loading @@ -228,8 +228,10 @@ public class FontListParser { return new Font(fullFilename, index, axes, weight, isItalic); return new Font(fullFilename, index, axes, weight, isItalic); } } /** The 'tag' attribute value is read as four character values between 0 and 255 inclusive. */ /** The 'tag' attribute value is read as four character values between U+0020 and U+007E private static final Pattern TAG_PATTERN = Pattern.compile("[\\x00-\\xFF]{4}"); * inclusive. */ private static final Pattern TAG_PATTERN = Pattern.compile("[\\x20-\\x7E]{4}"); /** The 'styleValue' attribute has an optional leading '-', followed by '<digits>', /** The 'styleValue' attribute has an optional leading '-', followed by '<digits>', * '<digits>.<digits>', or '.<digits>' where '<digits>' is one or more of [0-9]. * '<digits>.<digits>', or '.<digits>' where '<digits>' is one or more of [0-9]. Loading graphics/tests/graphicstests/src/android/graphics/VariationParserTest.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -104,6 +104,15 @@ public class VariationParserTest extends TestCase { assertEquals(1, axis.length); assertEquals(1, axis.length); } } @SmallTest public void testInvalidTagCharacters() { FontListParser.Axis[] axis = FontListParser.parseFontVariationSettings("'\u0000\u0000\u0000\u0000' 10"); assertEquals(0, axis.length); axis = FontListParser.parseFontVariationSettings("'\u3042\u3044\u3046\u3048' 10"); assertEquals(0, axis.length); } @SmallTest @SmallTest public void testMakeTag() { public void testMakeTag() { assertEquals(0x77647468, FontListParser.makeTag('w', 'd', 't', 'h')); assertEquals(0x77647468, FontListParser.makeTag('w', 'd', 't', 'h')); Loading Loading
graphics/java/android/graphics/FontListParser.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -155,7 +155,7 @@ public class FontListParser { @VisibleForTesting @VisibleForTesting public static int makeTag(char c1, char c2, char c3, char c4) { public static int makeTag(char c1, char c2, char c3, char c4) { return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4; return (c1 << 24) | (c2 << 16) | (c3 << 8) | c4; } } private static boolean isSpacer(char c) { private static boolean isSpacer(char c) { Loading Loading @@ -228,8 +228,10 @@ public class FontListParser { return new Font(fullFilename, index, axes, weight, isItalic); return new Font(fullFilename, index, axes, weight, isItalic); } } /** The 'tag' attribute value is read as four character values between 0 and 255 inclusive. */ /** The 'tag' attribute value is read as four character values between U+0020 and U+007E private static final Pattern TAG_PATTERN = Pattern.compile("[\\x00-\\xFF]{4}"); * inclusive. */ private static final Pattern TAG_PATTERN = Pattern.compile("[\\x20-\\x7E]{4}"); /** The 'styleValue' attribute has an optional leading '-', followed by '<digits>', /** The 'styleValue' attribute has an optional leading '-', followed by '<digits>', * '<digits>.<digits>', or '.<digits>' where '<digits>' is one or more of [0-9]. * '<digits>.<digits>', or '.<digits>' where '<digits>' is one or more of [0-9]. Loading
graphics/tests/graphicstests/src/android/graphics/VariationParserTest.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -104,6 +104,15 @@ public class VariationParserTest extends TestCase { assertEquals(1, axis.length); assertEquals(1, axis.length); } } @SmallTest public void testInvalidTagCharacters() { FontListParser.Axis[] axis = FontListParser.parseFontVariationSettings("'\u0000\u0000\u0000\u0000' 10"); assertEquals(0, axis.length); axis = FontListParser.parseFontVariationSettings("'\u3042\u3044\u3046\u3048' 10"); assertEquals(0, axis.length); } @SmallTest @SmallTest public void testMakeTag() { public void testMakeTag() { assertEquals(0x77647468, FontListParser.makeTag('w', 'd', 't', 'h')); assertEquals(0x77647468, FontListParser.makeTag('w', 'd', 't', 'h')); Loading