Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #26 #27

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/kotlin/burp/BurpExtender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import java.beans.PropertyChangeListener
import java.beans.PropertyChangeSupport
import java.io.BufferedReader
import java.io.File
import java.io.PrintStream
import java.net.URL
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
Expand Down Expand Up @@ -439,7 +440,18 @@ class BurpExtender : IBurpExtender, ITab, ListDataListener, IHttpListener {
if (selectionContext != null) {
val (context, bounds) = selectionContext
if (context in rr.contexts) {
val body = bytes.copyOfRange(bounds[0], bounds[1])
val body = try {
// handle utf-8 content
bytes.decodeToString(throwOnInvalidSequence=true).substring(bounds[0], bounds[1]).encodeToByteArray()
} catch (ex: java.nio.charset.MalformedInputException) {
// Converting to utf-8 string failed.
// Revert to plain byte extraction
bytes.copyOfRange(bounds[0], bounds[1])
} catch (ex: Exception) {
// What happened here?
ex.printStackTrace(PrintStream(callbacks.getStderr()))
bytes.copyOfRange(bounds[0], bounds[1])
}
selections.add(MessageInfo(body, helpers.bytesToString(body), headers, url, it))
}
}
Expand Down