Skip to content

Commit

Permalink
fix: 🐛 Fix the BUG in JMeter files caused by the presence of escape c…
Browse files Browse the repository at this point in the history
…haracters, resulting in an error when opening the file.
  • Loading branch information
linwumingshi committed Jan 26, 2024
1 parent 04b248f commit 3ca3a0a
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 3ca3a0a

Please sign in to comment.