Skip to content

Commit

Permalink
Merge pull request #713 from linwumingshi/fix/jmeter-file-escape-char…
Browse files Browse the repository at this point in the history
…acters

fix: 🐛 Fix the BUG in JMeter files caused by the presence of escape characters, resulting in an error when opening the file.
  • Loading branch information
shalousun authored Jan 26, 2024
2 parents 04b248f + 3ca3a0a commit f53dc7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/ly/doc/utils/DocUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,11 @@ public static String getEscapeAndCleanComment(String comment) {
if (StringUtil.isEmpty(comment)) {
return "";
}
return comment.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;");
return comment.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll("\"", "&quot;")
.replaceAll("'", "&apos;");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/template/JMeter.jmx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<%
for(doc in api.list){
%>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${doc.desc}" enabled="true">
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${@com.ly.doc.utils.DocUtil.getEscapeAndCleanComment(doc.desc)}" enabled="true">
<%if(isNotEmpty(doc.requestExample.jsonBody)){%>
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
Expand Down

0 comments on commit f53dc7e

Please sign in to comment.