Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENKINS-69544 - Enable parser to handle XML control characters in args tag #52

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<connection>scm:git:ssh://github.com/jenkinsci/robot-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/robot-plugin.git</developerConnection>
<url>https://www.github.com/jenkinsci/robot-plugin</url>
<tag>robot-2.0.0</tag>
<tag>HEAD</tag>
</scm>
<dependencyManagement>
<dependencies>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/hudson/plugins/robot/RobotParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ private String processArgs(XMLStreamReader reader) throws XMLStreamException {
}
if (reader.isStartElement() && xmlTag.equals("arg")) {
reader.next();
stringBuilder.append(" ").append(reader.getText());
try {
stringBuilder.append(" ").append(reader.getText());
} catch (IllegalStateException ignore) { }
}
}
reader.next();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/hudson/plugins/robot/RobotParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,11 @@ public void testRobot5TryExceptFinallyWhileContinue() {
final String mask = "basic_new_features_output.xml";
parse(dir, mask);
}

@Test
public void testEmptyArgTags() {
final String dir = ".";
final String mask = "empty_args-output.xml";
parse(dir, mask);
}
}
41 changes: 41 additions & 0 deletions src/test/resources/hudson/plugins/robot/empty_args-output.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<robot generator="Robot 5.0.1 (Python 3.9.5 on linux)" generated="20220906 18:43:11.777" rpa="false" schemaversion="3">
<suite id="s1" name="test" source="/home/test.robot">
<test id="s1-t1" name="test" line="32">
<kw name="My keyword">
<tag>step 7</tag>
<msg timestamp="20220906 18:44:42.970" level="TRACE">Arguments: [ ]</msg>
<kw name="Write Bare" library="SSHLibrary">
<arg>arg 1</arg>
<arg></arg>
<arg>arg 3</arg>
<doc>Writes the given ``text`` on the remote machine without appending a newline.</doc>
<msg timestamp="20220906 18:44:56.358" level="TRACE">Arguments: [ '\x03' ]</msg>
<msg timestamp="20220906 18:44:56.359" level="TRACE">Return: None</msg>
<status status="PASS" starttime="20220906 18:44:56.358" endtime="20220906 18:44:56.359"/>
</kw>
<msg timestamp="20220906 18:44:56.381" level="TRACE">Return: None</msg>
<status status="PASS" starttime="20220906 18:44:42.970" endtime="20220906 18:44:56.381"/>
</kw>
<tag>some_tag</tag>
<tag>TOTAL PASSED</tag>
<status status="PASS" starttime="20220906 18:43:25.252" endtime="20220906 18:44:56.389"/>
</test>
<doc>Some documentation</doc>
<status status="PASS" starttime="20220906 18:43:11.879" endtime="20220906 18:44:56.822"/>
</suite>
<statistics>
<total>
<stat pass="1" fail="0" skip="0">All Tests</stat>
</total>
<tag>
<stat pass="1" fail="0" skip="0">test</stat>
<stat pass="1" fail="0" skip="0">TOTAL PASSED</stat>
</tag>
<suite>
<stat pass="1" fail="0" skip="0" id="s1" name="test">test</stat>
</suite>
</statistics>
<errors>
</errors>
</robot>