Skip to content

Commit 9fb40b6

Browse files
nitzanjtocker
authored andcommitted
Fix double encoding for commas and slashes in text layers (#66)
Encode comma to %252C and slash to %252F
1 parent 46af431 commit 9fb40b6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

cloudinary-core/src/main/java/com/cloudinary/transformation/TextLayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public TextLayer text(String text) {
9696
start = m.end();
9797
}
9898
result.append(SmartUrlEncoder.encode(text.substring(start)));
99-
this.text = result.toString().replace("%2C", "%E2%80%9A").replace("/", "%E2%81%84");
99+
this.text = result.toString().replace("%2C", "%252C").replace("/", "%252F");
100100
return getThis();
101101
}
102102

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,13 @@ public void testOverlayOptions() {
964964
"logo.png",
965965
new Layer().resourceType("video").publicId("cat"),
966966
"video:cat",
967+
new TextLayer().text("Hello/World").fontFamily("Arial").fontSize(18),
968+
"text:Arial_18:Hello%252FWorld",
967969
new TextLayer().text("Hello World, Nice to meet you?").fontFamily("Arial").fontSize(18),
968-
"text:Arial_18:Hello%20World%E2%80%9A%20Nice%20to%20meet%20you%3F",
970+
"text:Arial_18:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
969971
new TextLayer().text("Hello World, Nice to meet you?").fontFamily("Arial").fontSize(18)
970972
.fontWeight("bold").fontStyle("italic").letterSpacing("4").lineSpacing(3),
971-
"text:Arial_18_bold_italic_letter_spacing_4_line_spacing_3:Hello%20World%E2%80%9A%20Nice%20to%20meet%20you%3F",
973+
"text:Arial_18_bold_italic_letter_spacing_4_line_spacing_3:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
972974
new SubtitlesLayer().publicId("sample_sub_en.srt"), "subtitles:sample_sub_en.srt",
973975
new SubtitlesLayer().publicId("sample_sub_he.srt").fontFamily("Arial").fontSize(40),
974976
"subtitles:Arial_40:sample_sub_he.srt"};
@@ -995,11 +997,13 @@ public void testBackwardCampatibleOverlayOptions() {
995997
"logo.png",
996998
new LayerBuilder().resourceType("video").publicId("cat"),
997999
"video:cat",
1000+
new TextLayerBuilder().text("Hello/World").fontFamily("Arial").fontSize(18),
1001+
"text:Arial_18:Hello%252FWorld",
9981002
new TextLayerBuilder().text("Hello World, Nice to meet you?").fontFamily("Arial").fontSize(18),
999-
"text:Arial_18:Hello%20World%E2%80%9A%20Nice%20to%20meet%20you%3F",
1003+
"text:Arial_18:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
10001004
new TextLayerBuilder().text("Hello World, Nice to meet you?").fontFamily("Arial").fontSize(18)
10011005
.fontWeight("bold").fontStyle("italic").letterSpacing("4"),
1002-
"text:Arial_18_bold_italic_letter_spacing_4:Hello%20World%E2%80%9A%20Nice%20to%20meet%20you%3F",
1006+
"text:Arial_18_bold_italic_letter_spacing_4:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
10031007
new SubtitlesLayerBuilder().publicId("sample_sub_en.srt"), "subtitles:sample_sub_en.srt",
10041008
new SubtitlesLayerBuilder().publicId("sample_sub_he.srt").fontFamily("Arial").fontSize(40),
10051009
"subtitles:Arial_40:sample_sub_he.srt"};

cloudinary-core/src/test/java/com/cloudinary/transformation/LayerTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ public void testLayerOptions() {
7272
"logo.png",
7373
new Layer().resourceType("video").publicId("cat"),
7474
"video:cat",
75+
new TextLayer().text("Hello/World").fontFamily("Arial").fontSize(18),
76+
"text:Arial_18:Hello%252FWorld",
7577
new TextLayer().text("Hello World, Nice to meet you?").fontFamily("Arial").fontSize(18),
76-
"text:Arial_18:Hello%20World%E2%80%9A%20Nice%20to%20meet%20you%3F",
78+
"text:Arial_18:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
7779
new TextLayer().text("Hello World, Nice to meet you?").fontFamily("Arial").fontSize(18)
7880
.fontWeight("bold").fontStyle("italic").letterSpacing("4"),
79-
"text:Arial_18_bold_italic_letter_spacing_4:Hello%20World%E2%80%9A%20Nice%20to%20meet%20you%3F",
81+
"text:Arial_18_bold_italic_letter_spacing_4:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
8082
new SubtitlesLayer().publicId("sample_sub_en.srt"), "subtitles:sample_sub_en.srt",
8183
new SubtitlesLayer().publicId("sample_sub_he.srt").fontFamily("Arial").fontSize(40),
8284
"subtitles:Arial_40:sample_sub_he.srt"};

0 commit comments

Comments
 (0)