mirror of https://github.com/apache/jmeter.git
Add ${__escapeXml()} function. Contributed by Michael Osipov (michaelo at apache.org)
This closes #288 on github. Bugzilla Id: 60883 git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1790429 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cebf1ae63b
commit
dd5eddddb2
|
|
@ -419,6 +419,12 @@ jmeter.reportgenerator.apdex_per_transaction=sample(\\d+):1000|2000;\
|
|||
|
||||
<h3>Functions</h3>
|
||||
<ul>
|
||||
<li><a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=60883">
|
||||
Bug
|
||||
60883</a>
|
||||
-
|
||||
<a href="https://github.com/apache/jmeter/pull/288">
|
||||
Pull request #288</a> - Add <span class="code">${__escapeXml()}</span> function. Contributed by Michael Osipov (michaelo at apache.org)</li>
|
||||
</ul>
|
||||
|
||||
<h3>I18N</h3>
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ Alternatively, just use <span class="code">/</span> instead for the path separat
|
|||
<tr><td>String</td><td> <a href="#__unescape">unescape</a></td><td>Process strings containing Java escapes (e.g. \n & \t)</td><td>2.3.3</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__unescapeHtml">unescapeHtml</a></td><td>Decode HTML-encoded strings</td><td>2.3.3</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__escapeHtml">escapeHtml</a></td><td>Encode strings using HTML encoding</td><td>2.3.3</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__escapeXml">escapeXml</a></td><td>Encode strings using XMl encoding</td><td>3.2</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__urldecode">urldecode</a></td><td>Decode a application/x-www-form-urlencoded string</td><td>2.10</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__urlencode">urlencode</a></td><td>Encode a string to a application/x-www-form-urlencoded string</td><td>2.10</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__TestPlanName">TestPlanName</a></td><td>Return name of current test plan</td><td>2.6</td></tr>
|
||||
|
|
@ -1305,6 +1306,26 @@ A reference name - <span class="code">refName</span> - for reusing the value cre
|
|||
</div><div class="required req-false">No</div></div>
|
||||
</div><div class="go-top"><a href="#">^</a></div></div>
|
||||
|
||||
<div class="component"><h2 id="__escapeXml">__escapeXml<a class="sectionlink" href="#__escapeXml" title="Link to here">¶</a></h2><div class="description">
|
||||
<p>
|
||||
Function which escapes the characters in a String using XML 1.0 entities.
|
||||
</p>
|
||||
<p>
|
||||
For example,<span class="code">"bread" & 'butter'</span>
|
||||
becomes:
|
||||
<span class="code">&quot;bread&quot; &amp; &apos;butter&apos;</span>.
|
||||
</p>
|
||||
<p>
|
||||
Uses <span class="code">StringEscapeUtils#escapeXml10(String)</span> from Commons Lang.
|
||||
</p>
|
||||
</div><div class="properties"><h3 id="__escapeXml_parms1">
|
||||
Parameters
|
||||
<a class="sectionlink" href="#__escapeXml_parms1" title="Link to here">¶</a></h3><div class="property title"><div class="name title">Attribute</div><div class="description title">Description</div><div class="required title">Required</div></div>
|
||||
<div class="property"><div class="name req-true">String to escape</div><div class="description req-true">
|
||||
The string to be escaped.
|
||||
</div><div class="required req-true">Yes</div></div>
|
||||
</div><div class="go-top"><a href="#">^</a></div></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="subsection"><h2 id="predefinedvars">21.6 Pre-defined Variables<a class="sectionlink" href="#predefinedvars" title="Link to here">¶</a></h2>
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ error_occurred=Error Occurred
|
|||
error_title=Error
|
||||
es=Spanish
|
||||
escape_html_string=String to escape
|
||||
escape_xml_string=String to escape
|
||||
eval_name_param=Text containing variable and function references
|
||||
evalvar_name_param=Name of variable
|
||||
example_data=Sample Data
|
||||
|
|
|
|||
|
|
@ -293,6 +293,7 @@ error_occurred=Une erreur est survenue
|
|||
error_title=Erreur
|
||||
es=Espagnol
|
||||
escape_html_string=Cha\u00EEne d'\u00E9chappement
|
||||
escape_xml_string=Cha\u00EEne d'\u00E9chappement
|
||||
eval_name_param=Variable contenant du texte et r\u00E9f\u00E9rences de fonctions
|
||||
evalvar_name_param=Nom de variable
|
||||
example_data=Exemple de donn\u00E9e
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.jmeter.functions;
|
||||
|
|
@ -59,13 +59,13 @@ public class TestSimpleFunctions extends JMeterTestCase {
|
|||
AbstractFunction function = new Uuid();
|
||||
checkInvalidParameterCounts(function, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testThreadNumberParameterCount() throws Exception {
|
||||
AbstractFunction function = new ThreadNumber();
|
||||
checkInvalidParameterCounts(function, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEscapeHtmlParameterCount() throws Exception {
|
||||
AbstractFunction function = new EscapeHtml();
|
||||
|
|
@ -77,19 +77,25 @@ public class TestSimpleFunctions extends JMeterTestCase {
|
|||
AbstractFunction function = new UnEscapeHtml();
|
||||
checkInvalidParameterCounts(function, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEscapeXmlParameterCount() throws Exception {
|
||||
AbstractFunction function = new EscapeXml();
|
||||
checkInvalidParameterCounts(function, 1, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnEscapeParameterCount() throws Exception {
|
||||
AbstractFunction function = new UnEscape();
|
||||
checkInvalidParameterCounts(function, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTestPlanParameterCount() throws Exception {
|
||||
AbstractFunction function = new TestPlanName();
|
||||
checkInvalidParameterCounts(function, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testThreadNumber() throws Exception {
|
||||
AbstractFunction function = new ThreadNumber();
|
||||
|
|
@ -97,8 +103,8 @@ public class TestSimpleFunctions extends JMeterTestCase {
|
|||
String ret = function.execute(result, null);
|
||||
assertEquals("1", ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testUuid() throws Exception {
|
||||
AbstractFunction function = new Uuid();
|
||||
|
|
@ -106,7 +112,7 @@ public class TestSimpleFunctions extends JMeterTestCase {
|
|||
String ret = function.execute(result, null);
|
||||
UUID.fromString(ret);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEscapeHtml() throws Exception {
|
||||
AbstractFunction function = new EscapeHtml();
|
||||
|
|
@ -115,7 +121,7 @@ public class TestSimpleFunctions extends JMeterTestCase {
|
|||
String ret = function.execute(result, null);
|
||||
assertEquals(""bread" & "butter"", ret);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnEscapeHtml() throws Exception {
|
||||
AbstractFunction function = new UnEscapeHtml();
|
||||
|
|
@ -124,7 +130,16 @@ public class TestSimpleFunctions extends JMeterTestCase {
|
|||
String ret = function.execute(result, null);
|
||||
assertEquals("\"bread\" & \"butter\"", ret);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEscapeXml() throws Exception {
|
||||
AbstractFunction function = new EscapeXml();
|
||||
params.add(new CompoundVariable("\"bread\" & <'butter'>"));
|
||||
function.setParameters(params);
|
||||
String ret = function.execute(result, null);
|
||||
assertEquals(""bread" & <'butter'>", ret);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTestPlanName() throws Exception {
|
||||
AbstractFunction function = new TestPlanName();
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ jmeter.reportgenerator.apdex_per_transaction=sample(\\d+):1000|2000;\
|
|||
|
||||
<h3>Functions</h3>
|
||||
<ul>
|
||||
<li><bug>60883</bug><pr>288</pr> - Add <code>${__escapeXml()}</code> function. Contributed by Michael Osipov (michaelo at apache.org)</li>
|
||||
</ul>
|
||||
|
||||
<h3>I18N</h3>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ Alternatively, just use <code>/</code> instead for the path separator - e.g. <co
|
|||
<tr><td>String</td><td> <a href="#__unescape">unescape</a></td><td>Process strings containing Java escapes (e.g. \n & \t)</td><td>2.3.3</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__unescapeHtml">unescapeHtml</a></td><td>Decode HTML-encoded strings</td><td>2.3.3</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__escapeHtml">escapeHtml</a></td><td>Encode strings using HTML encoding</td><td>2.3.3</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__escapeXml">escapeXml</a></td><td>Encode strings using XMl encoding</td><td>3.2</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__urldecode">urldecode</a></td><td>Decode a application/x-www-form-urlencoded string</td><td>2.10</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__urlencode">urlencode</a></td><td>Encode a string to a application/x-www-form-urlencoded string</td><td>2.10</td></tr>
|
||||
<tr><td>String</td><td> <a href="#__TestPlanName">TestPlanName</a></td><td>Return name of current test plan</td><td>2.6</td></tr>
|
||||
|
|
@ -1476,6 +1477,28 @@ A reference name - <code>refName</code> - for reusing the value created by this
|
|||
</properties>
|
||||
</component>
|
||||
|
||||
<component index="§-num;.5.33" name="__escapeXml">
|
||||
<description>
|
||||
<p>
|
||||
Function which escapes the characters in a String using XML 1.0 entities.
|
||||
</p>
|
||||
<p>
|
||||
For example,<code>"bread" & 'butter'</code>
|
||||
becomes:
|
||||
<code>&quot;bread&quot; &amp; &apos;butter&apos;</code>.
|
||||
</p>
|
||||
<p>
|
||||
Uses <code>StringEscapeUtils#escapeXml10(String)</code> from Commons Lang.
|
||||
</p>
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<property name="String to escape" required="Yes">
|
||||
The string to be escaped.
|
||||
</property>
|
||||
</properties>
|
||||
</component>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name="§-num;.6 Pre-defined Variables" anchor="predefinedvars">
|
||||
|
|
|
|||
Loading…
Reference in New Issue