The Burp Suite User Forum was discontinued on the 1st November 2024.

Burp Suite User Forum

For support requests, go to the Support Center. To discuss with other Burp users, head to our Discord page.

SUPPORT CENTER DISCORD

Montoya-API: caretPosition larger than request body on MessageEditorHttpRequestResponse

Mbharanya | Last updated: Feb 23, 2023 03:30PM UTC

Hi there, I'm developing a new extension using the Montoya API. I'm planning to register a new `ContextMenuItemsProvider` which provides a way to insert a string at a certain position into the request body in the repeater view. To accomplish this I am creating a new `ActionListener` and using `ContextMenuEvent.messageEditorRequestResponse`. However I noticed that when using `MessageEditorHttpRequestResponse.caretPosition` it tends to be larger than the entire request body. Is this intended behaviour? This makes it very hard to add a custom String at the current cursor position of the user, which I think must be a common requirement. See my code snippet for illustration: ```java HttpRequest request = m.requestResponse().request(); var body = request.body().getBytes(); var position = m.caretPosition(); // position == 1152 // body.length == 357 ``` If relevant I am using the following HTTP request in the Repeater view: ```` POST / HTTP/1.1 Host: localhost:5000 Content-Length: 353 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryFLaImAqsCCMNhfkd Connection: close ------WebKitFormBoundaryFLaImAqsCCMNhfkd Content-Disposition: form-data; name="file"; filename="Book1.xlsx" Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet --insert here-- ------WebKitFormBoundaryFLaImAqsCCMNhfkd-- ```

Hannah, PortSwigger Agent | Last updated: Feb 24, 2023 04:33PM UTC