Skip to content

Commit

Permalink
Kotlin: Do not escape/sanitize quoted enum values (#18305)
Browse files Browse the repository at this point in the history
  • Loading branch information
tajobe committed Apr 7, 2024
1 parent a91d8e2 commit 560089e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ public String toEnumValue(String value, String datatype) {
} else if ("kotlin.Float".equals(datatype)) {
return value + "f";
} else {
return "\"" + escapeText(value) + "\"";
return "\"" + value + "\"";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void originalEnumConverter() {
assertEquals(codegen.toEnumVarName("long Name", null), "long_Name");
assertEquals(codegen.toEnumVarName("1long Name", null), "_1long_Name");
assertEquals(codegen.toEnumVarName("not1long Name", null), "not1long_Name");
assertEquals(codegen.toEnumVarName("data/*", null), "dataSlashStar");
}
@Test
public void pascalCaseEnumConverter() {
Expand All @@ -78,6 +79,7 @@ public void toEnumValue() {
assertEquals(codegen.toEnumValue("5", "kotlin.Float"), "5f");
assertEquals(codegen.toEnumValue("1.0", "kotlin.Float"), "1.0f");
assertEquals(codegen.toEnumValue("data", "Something"), "\"data\"");
assertEquals(codegen.toEnumValue("data/*", "Something"), "\"data/*\"");
}

private static class P_AbstractKotlinCodegen extends AbstractKotlinCodegen {
Expand Down

0 comments on commit 560089e

Please sign in to comment.