forked from loafle/openapi-generator-original
[powershell-experimental] ValidatePattern with double-quote (") throws-exception (#5956)
* ValidatePattern having double quote(") throws exception on running Build.ps1 * fix tab with space Co-authored-by: Ghufran Zahidi <gzahidi@cisco.com>
This commit is contained in:
parent
896867b5e7
commit
0adc20f114
@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
|
||||
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;
|
||||
@ -622,6 +623,28 @@ public class PowerShellExperimentalClientCodegen extends DefaultCodegen implemen
|
||||
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("<#", "<_#");
|
||||
|
@ -689,6 +689,7 @@ components:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
pattern: '["A-Z]+-[0-9][0-9]'
|
||||
phone:
|
||||
type: string
|
||||
userStatus:
|
||||
|
@ -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)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user