Skip to content

Commit c48d189

Browse files
committed
fix: update SIMPLE_OVERLAY_TEXT_REGEX to allow only safe characters in overlay text
1 parent 64c5374 commit c48d189

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/url/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ImageOverlay, SolidColorOverlay, SubtitleOverlay, TextOverlay, Transfor
33
import transformationUtils, { safeBtoa } from "../utils/transformation";
44
const TRANSFORMATION_PARAMETER = "tr";
55
const SIMPLE_OVERLAY_PATH_REGEX = new RegExp('^[a-zA-Z0-9-._/ ]*$')
6-
const SIMPLE_OVERLAY_TEXT_REGEX = new RegExp('^[a-zA-Z0-9-._ ]*$') // These characters are selected by testing actual URLs on both path and query parameters. If and when backend starts supporting wide range of characters, this regex should be updated to improve URL readability.
6+
const SIMPLE_OVERLAY_TEXT_REGEX = new RegExp('^[a-zA-Z0-9._ ]*$') // These characters are selected by testing actual URLs on both path and query parameters. If and when backend starts supporting wide range of characters, this regex should be updated to improve URL readability.
77

88
function removeTrailingSlash(str: string) {
99
if (typeof str == "string" && str[str.length - 1] == "/") {

test/url-generation/overlay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ describe("Overlay encoding test cases", function () {
324324
transformation: [{
325325
overlay: {
326326
type: "text",
327-
text: "alnum123-._ ",
327+
text: "alnum123._ ",
328328
}
329329
}]
330330
});
331-
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-text,i-${encodeURIComponent("alnum123-._ ")},l-end/medium_cafe_B1iTdD0C.jpg`);
331+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-text,i-${encodeURIComponent("alnum123._ ")},l-end/medium_cafe_B1iTdD0C.jpg`);
332332
});
333333

334334
it('Non simple text overlay, should use ie instead of i', function () {

0 commit comments

Comments
 (0)