Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ValidatePattern having double quote(") throws exception on running Bu…
…ild.ps1
  • Loading branch information
Ghufz committed Apr 16, 2020
commit ad24d348d28835edfc90385a33357d6d51eef02d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
Expand Down Expand Up @@ -622,6 +623,29 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("appveyor.mustache", "", "appveyor.yml"));
}

@SuppressWarnings("static-method")
@Override
public String escapeText(String input) {

if (input == null) {
return input;
}

// remove \t, \n, \r
// replace \ with \\
// replace " with \"
// outter unescape to retain the original multi-byte characters
// finally escalate characters avoiding code injection
return escapeUnsafeCharacters(
StringEscapeUtils.unescapeJava(
StringEscapeUtils.escapeJava(input)
.replace("\\/", "/"))
.replaceAll("[\\t\\n\\r]", " ")
.replace("\\", "\\\\")
.replace("\"", "\"\""));

}

@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("#>", "#_>").replace("<#", "<_#");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ components:
type: string
password:
type: string
pattern: '["A-Z]+-[0-9][0-9]'
phone:
type: string
userStatus:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function Initialize-PSUser {
[String]
${Email},
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
[ValidatePattern("[""A-Z]+-[0-9][0-9]")]
[String]
${Password},
[Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
Expand Down