Skip to content

Commit

Permalink
Update ChinesePanel.java
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed May 12, 2024
1 parent 738509d commit efb188a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/messageTab/U2C/ChinesePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void search(String searchTerm, boolean isRegex, boolean isCaseSensitive)
}
}
int num = textArea.getHighlighter().getHighlights().length;
statusLabel.setText(" "+num + " matches");
statusLabel.setText(" " + num + " matches");
}


Expand All @@ -259,19 +259,22 @@ private void search(String searchTerm, boolean isRegex, boolean isCaseSensitive)
public void display(byte[] content, boolean isRequest, String currentCharset) {
HelperPlus getter = BurpExtender.getHelperPlus();

int position = textArea.getCaretPosition();

try {
byte[] newContent = handleContent(content, isRequest, currentCharset);

if (getter.isJSON(content, isRequest)) {
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
} else if (getter.isJavaScript(content, isRequest)){
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
} else if (getter.isJavaScript(content, isRequest)) {
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
} else {
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML);
}

try {
textArea.setText(new String(newContent, currentCharset));
textArea.setCaretPosition(position);
} catch (UnsupportedEncodingException e) {
textArea.setText(e.getMessage());
}
Expand All @@ -285,6 +288,7 @@ public void display(byte[] content, boolean isRequest, String currentCharset) {
e.printStackTrace(pw);
String stackTrace = sw.toString();
textArea.setText(stackTrace);
textArea.setCaretPosition(position);
}
}

Expand Down Expand Up @@ -318,8 +322,13 @@ public static byte[] handleContent(byte[] content, boolean isRequest, String cha
} else {
int i = 0;
while (TextUtils.needUnicodeConvert(contentStr) && i < 3) {
int oldLength = contentStr.length();
contentStr = StringEscapeUtils.unescapeJava(contentStr);
i++;
int newLength = contentStr.length();
if (oldLength == newLength) {
break;
}
}

displayContent = contentStr.getBytes(charSet);
Expand Down

0 comments on commit efb188a

Please sign in to comment.