@@ -60,14 +60,10 @@ private void processField(FieldNode field) {
6060 }
6161 FilledNewArrayNode filledArr = (FilledNewArrayNode ) insn ;
6262 ArgType elemType = filledArr .getElemType ();
63- byte [] bytes ;
64- if (ArgType .BYTE .equals (elemType )) {
65- bytes = extractLiteralBytes (filledArr );
66- } else if (ArgType .INT .equals (elemType )) {
67- bytes = extractIntAsAsciiBytes (filledArr );
68- } else {
63+ if (!ArgType .BYTE .equals (elemType ) && !ArgType .INT .equals (elemType )) {
6964 return ;
7065 }
66+ byte [] bytes = extractLiteralBytes (filledArr );
7167 if (bytes == null || bytes .length == 0 ) {
7268 return ;
7369 }
@@ -78,19 +74,6 @@ private void processField(FieldNode field) {
7874 }
7975
8076 private static byte [] extractLiteralBytes (FilledNewArrayNode insn ) {
81- int count = insn .getArgsCount ();
82- byte [] bytes = new byte [count ];
83- for (int i = 0 ; i < count ; i ++) {
84- InsnArg arg = insn .getArg (i );
85- if (!(arg instanceof LiteralArg )) {
86- return null ;
87- }
88- bytes [i ] = (byte ) ((LiteralArg ) arg ).getLiteral ();
89- }
90- return bytes ;
91- }
92-
93- private static byte [] extractIntAsAsciiBytes (FilledNewArrayNode insn ) {
9477 int count = insn .getArgsCount ();
9578 byte [] bytes = new byte [count ];
9679 for (int i = 0 ; i < count ; i ++) {
@@ -113,13 +96,7 @@ private String tryDecodeAsString(byte[] bytes) {
11396 .onMalformedInput (CodingErrorAction .REPORT )
11497 .onUnmappableCharacter (CodingErrorAction .REPORT );
11598 String decoded = utf8 .decode (ByteBuffer .wrap (bytes )).toString ();
116- if (decoded .isEmpty ()) {
117- return null ;
118- }
119- long printableCount = decoded .chars ()
120- .filter (c -> (c >= 32 && c <= 126 ) || c == '\t' || c == '\n' || c == '\r' )
121- .count ();
122- if ((double ) printableCount / decoded .length () < options .getByteArrayMinPrintableRatio ()) {
99+ if (!B64Detector .isPrintable (decoded , options .getByteArrayMinPrintableRatio ())) {
123100 return null ;
124101 }
125102 int minDecoded = options .getMinDecodedLength ();
0 commit comments