Burp Suite User Forum

Create new post

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

Hi Could you drop us an email at support@portswigger.net with some more information and a working POC of your code so we can take a look, please?

You must be an existing, logged-in customer to reply to a thread. Please email us for additional support.