Committed by
Gerrit Code Review
Updating ApplicationArchive.isPlainXml() to exclude files that begin with zip magic bytes
Change-Id: I0a7b2c64dfb9b1118164023442dcf7871fc2b587
Showing
1 changed file
with
4 additions
and
2 deletions
... | @@ -71,6 +71,7 @@ public class ApplicationArchive | ... | @@ -71,6 +71,7 @@ public class ApplicationArchive |
71 | 71 | ||
72 | // Magic strings to search for at the beginning of the archive stream | 72 | // Magic strings to search for at the beginning of the archive stream |
73 | private static final String XML_MAGIC = "<?xml "; | 73 | private static final String XML_MAGIC = "<?xml "; |
74 | + private static final String ZIP_MAGIC = "PK"; | ||
74 | 75 | ||
75 | // Magic strings to search for and how deep to search it into the archive stream | 76 | // Magic strings to search for and how deep to search it into the archive stream |
76 | private static final String APP_MAGIC = "<app "; | 77 | private static final String APP_MAGIC = "<app "; |
... | @@ -218,8 +219,9 @@ public class ApplicationArchive | ... | @@ -218,8 +219,9 @@ public class ApplicationArchive |
218 | 219 | ||
219 | // Indicates whether the stream encoded in the given bytes is plain XML. | 220 | // Indicates whether the stream encoded in the given bytes is plain XML. |
220 | private boolean isPlainXml(byte[] bytes) { | 221 | private boolean isPlainXml(byte[] bytes) { |
221 | - return substring(bytes, XML_MAGIC.length()).equals(XML_MAGIC) || | 222 | + return !substring(bytes, ZIP_MAGIC.length()).equals(ZIP_MAGIC) && |
222 | - substring(bytes, APP_MAGIC_DEPTH).contains(APP_MAGIC); | 223 | + (substring(bytes, XML_MAGIC.length()).equals(XML_MAGIC) || |
224 | + substring(bytes, APP_MAGIC_DEPTH).contains(APP_MAGIC)); | ||
223 | } | 225 | } |
224 | 226 | ||
225 | // Returns the substring of maximum possible length from the specified bytes. | 227 | // Returns the substring of maximum possible length from the specified bytes. | ... | ... |
-
Please register or login to post a comment