Bug 53957 - HTTP Request : In Parameters tab, allow pasting of content coming from Firefox and Chrome (unparsed)
Summary: HTTP Request : In Parameters tab, allow pasting of content coming from Firefo...
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.7
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
: 57201 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-10-03 09:41 UTC by oliver lloyd
Modified: 2017-11-05 22:53 UTC (History)
3 users (show)



Attachments
HTTP arguments delimiter (3.91 KB, patch)
2017-11-03 01:47 UTC, Andrew Burton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description oliver lloyd 2012-10-03 09:41:58 UTC
The current feature where lists of values in the clipboard can be pasted into query params, URL filters, etc. requires that the data be tab separated. It would make sense if this data were also parse using a semicolon because tools such as Chrome Dev Tools will use this delimeter and this is probably the most likely source for copying such lists.

This enhancement would remove the step currently required to replace the ':' with a \t.
Comment 1 Philippe Mouawad 2012-10-11 21:00:09 UTC
Hello Oliver,
How would we decide if separator is : or \t ?
What if \t is inside of value or : is ?

Thanks
Comment 2 oliver lloyd 2012-10-11 21:32:29 UTC
Fair point. Would it make sense to not use '\t' at all and only parse on ':'?

Both Chrome and Firefox use semicolons so the use case supports this change.

Note. Firefox (v13 on OSX) will separate lines using a comma, which still needs replacing with a linefeed but the key values are split on semicolon.

The reason why I think using semicolons in place of tabs is better is because I think that in most cases this feature will be used in this manner - to copy and paste headers and params directly from a browser inspect window.

Another reason to support the change is simply that it is, arguably, non standard to use tabs to separate key value pairs, whereas the use of a semicolon is standard.
Comment 3 Sebb 2012-10-12 01:53:55 UTC
(In reply to comment #2)
> Fair point. Would it make sense to not use '\t' at all and only parse on ':'?
> 
> Both Chrome and Firefox use semicolons so the use case supports this change.

I assume you mean colon (:) rather than semicolon (;) as it is colon (:) that is used to separate header names from their values.

==

Note that changing the separator may cause problems; ideally it should be possible to choose which to use. When stuff is pasted using a document or spreadsheet editor the user can choose whether it is treated as plain text or formatted text; maybe something similar can be done in JMeter? This might require Java 6 (which would be OK).
Comment 4 oliver lloyd 2012-10-12 08:26:23 UTC
Yes, colon, not semicolon!

Agreed, I think that it would be good to be able to setup some options that decide how the data is parsed. You could choose the separator and also tell the parser to break on new line when it sees commas (to get around the Firefox problem). But I don't think these config settings should be inline to the process. I.e. I should be able to set them once and not have to repeatedly choose them each time I press the Add From Clipboard button.

I guess the simplest method would be to have a couple of new properties in the config file?
Comment 5 Sebb 2012-10-12 11:38:54 UTC
Using properties would be the simplest method to implement.

But surely the format of the clipboard data is going to vary, and the user may not know before starting JMeter? It would be very annoying to have to restart JMeter to change the delimiter.

Also, the default delimiter surely depends on the target of the paste?

e.g. headers will probably have colon, URL parameters will have & and ? etc.
Comment 6 oliver lloyd 2012-10-12 11:49:29 UTC
You could be right, it might be that other users would have varying delimiters - I an only speculate based on my own experience. But my feeling is that most people will use this feature as I do, to copy and paste values from the inspect windows of browsers. In this case, then the delimiter is always (Firefox + Chrome) a colon, this is true for both headers and url params. (When you copy URL params from a browser inspect window they are also separated by colons.)


*Except* 
There is one more use case which is possibly even more prevalent that copying from a browser and this is copying within JMeter itself. I often want to copy headers and URL params from one sampler to another and if this only works when the data is tab delimited then that pretty much destroys my request. Sorry, I should have thought of that sooner..
Comment 7 Philippe Mouawad 2014-11-26 21:03:41 UTC
*** Bug 57201 has been marked as a duplicate of this bug. ***
Comment 8 subhojit777 2017-04-26 11:31:48 UTC
I managed to do this as follows:

- Add HTTP Header Manager
- Copy the info, and use "Add from Clipboard", HTTP Header Manager parses the colon : and splits it into header value format
- Now that you have everything in HTTP Header Manager, copy all the info from there and use "Add from Clipboard" in HTTP Request parameters. This will paste everything in correct format.
Comment 9 Andrew Burton 2017-11-03 01:47:55 UTC
Created attachment 35479 [details]
HTTP arguments delimiter

Wouldn't the biggest use-case for copying-pasting HTTP arguments be from a Chrome or Firefox dev tab? In that case, we could easily make the case that the default argument separator would be ':' and line separator would be '&'.

If copying/pasting from other arguments, which would take '\t' and '\n' as the separators, that could be a separate check.

I've attached a patch (also posted to the JMeter Dev mailing list) that applies this to HTTPArgumentsPanel.java

This bug has been open for 5 years now and it's one of my biggest bug-bears about copying query parameters into the HTTP Arguments panel.

We also have separate classes for the HeaderArguments panel and generic Arguments panel, so any specific delimiter could be applied there, rather than making a delimiter in the already comprehensive set of config parameters.
Comment 10 Andrew Burton 2017-11-03 02:04:06 UTC
(In reply to subhojit777 from comment #8)
> I managed to do this as follows:
> 
> - Add HTTP Header Manager
> - Copy the info, and use "Add from Clipboard", HTTP Header Manager parses
> the colon : and splits it into header value format
> - Now that you have everything in HTTP Header Manager, copy all the info
> from there and use "Add from Clipboard" in HTTP Request parameters. This
> will paste everything in correct format.

While this is a workaround, this shouldn't be what we advocate as the solution.
Comment 11 Philippe Mouawad 2017-11-03 09:30:48 UTC
Thanks for patch.
See my notes below.
(In reply to Andrew Burton from comment #9)
> Created attachment 35479 [details]
> HTTP arguments delimiter
> 
> Wouldn't the biggest use-case for copying-pasting HTTP arguments be from a
> Chrome or Firefox dev tab? In that case, we could easily make the case that
> the default argument separator would be ':' and line separator would be '&'.


In your code you didn't use colon but equal , why :
private static final String CLIPBOARD_ARG_DELIMITERS = "\t|="; //$NON-NLS-1$

So this does not pastes correctly "parsed parameters" from Chrome

But replacing it with :
private static final String CLIPBOARD_ARG_DELIMITERS = "\t|=|:"; //$NON-NLS-1$

Can lead to wrong pasting when value is an url that contains ':'

> 
> If copying/pasting from other arguments, which would take '\t' and '\n' as
> the separators, that could be a separate check.
> 
> I've attached a patch (also posted to the JMeter Dev mailing list) that
> applies this to HTTPArgumentsPanel.java
> 
> This bug has been open for 5 years now and it's one of my biggest bug-bears
> about copying query parameters into the HTTP Arguments panel.
> 
> We also have separate classes for the HeaderArguments panel and generic
> Arguments panel, so any specific delimiter could be applied there, rather
> than making a delimiter in the already comprehensive set of config
> parameters.
Comment 12 Philippe Mouawad 2017-11-04 11:05:19 UTC
Author: pmouawad
Date: Sat Nov  4 11:04:37 2017
New Revision: 1814275

URL: http://svn.apache.org/viewvc?rev=1814275&view=rev
Log:
Bug 53957 - HTTP Request : In Parameters tab, allow pasting of content coming from Firefox and Chrome (unparsed)
Bugzilla Id: 53957

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HTTPArgumentsPanel.java
    jmeter/trunk/xdocs/changes.xml
Comment 13 Andrew Burton 2017-11-05 22:53:15 UTC
> > Wouldn't the biggest use-case for copying-pasting HTTP arguments be from a
> > Chrome or Firefox dev tab? In that case, we could easily make the case that
> > the default argument separator would be ':' and line separator would be '&'.
> 
> 
> In your code you didn't use colon but equal , why :
> private static final String CLIPBOARD_ARG_DELIMITERS = "\t|="; //$NON-NLS-1$
> 
> So this does not pastes correctly "parsed parameters" from Chrome

Apologies - my mistake: I handled the use case for copying the URL, but not the contents of the Query String Parameters section in Chrome dev tools.

> But replacing it with :
> private static final String CLIPBOARD_ARG_DELIMITERS = "\t|=|:";
> //$NON-NLS-1$
> 
> Can lead to wrong pasting when value is an url that contains ':'
> 

You're right - we would have to assume in that case that the user is entering a query string that has been URL encoded correctly?

In the short term, I could add a FIXME TODO comment to the code to handle that edge case.
Comment 14 The ASF infrastructure team 2022-09-24 20:37:51 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2943