Author: pmouawad
Date: Fri Nov  3 09:36:16 2017
New Revision: 1814153

URL: http://svn.apache.org/viewvc?rev=1814153&view=rev
Log:
Bug 61716 - Header Manager : When pasting Headers from Firefox or Chrome spaces 
are introduced as first character of value
Bugzilla Id: 61716

Modified:
    
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java
    jmeter/trunk/xdocs/changes.xml

Modified: 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java?rev=1814153&r1=1814152&r2=1814153&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java
 (original)
+++ 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/HeaderPanel.java
 Fri Nov  3 09:36:16 2017
@@ -54,6 +54,15 @@ import org.slf4j.Logger;
  */
 public class HeaderPanel extends AbstractConfigGui implements ActionListener
 {
+    /** When pasting from the clipboard, split lines on linebreak */
+    private static final String CLIPBOARD_LINE_DELIMITER = "\n"; //$NON-NLS-1$
+
+    /** When pasting from the clipboard, split parameters on ':' */
+    private static final String CLIPBOARD_COLON_DELIMITER = ":"; //$NON-NLS-1$
+
+    /** When pasting from the clipboard, split parameters on '\t' */
+    private static final String CLIPBOARD_TAB_DELIMITER = "\t";
+    
     private static final long serialVersionUID = 241L;
 
     private static final Logger log = 
LoggerFactory.getLogger(HeaderPanel.class);
@@ -243,15 +252,15 @@ public class HeaderPanel extends Abstrac
             if(clipboardContent == null) {
                 return;
             }
-            String[] clipboardLines = clipboardContent.split("\n"); // 
$NON-NLS-1$
+            String[] clipboardLines = 
clipboardContent.split(CLIPBOARD_LINE_DELIMITER); // $NON-NLS-1$
             for (String clipboardLine : clipboardLines) {
-                int index = clipboardLine.indexOf(":"); // $NON-NLS-1$
+                int index = clipboardLine.indexOf(CLIPBOARD_COLON_DELIMITER); 
// $NON-NLS-1$
                 if(index < 0) {
                     // when pasting from another header panel the values are 
separated with '\t'
-                    index = clipboardLine.indexOf("\t");
+                    index = clipboardLine.indexOf(CLIPBOARD_TAB_DELIMITER);
                 }
                 if (index > 0) {
-                    Header header = new Header(clipboardLine.substring(0, 
index), clipboardLine.substring(index+1));
+                    Header header = new Header(clipboardLine.substring(0, 
index).trim(), clipboardLine.substring(index+1).trim());
                     headerManager.add(header);
                 }
             }

Modified: jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1814153&r1=1814152&r2=1814153&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Nov  3 09:36:16 2017
@@ -185,6 +185,7 @@ Summary
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
+    <li><bug>61716</bug>Header Manager : When pasting Headers from Firefox or 
Chrome spaces are introduced as first character of value</li>
 </ul>
 
 <h3>Functions</h3>


Reply via email to