Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion lib-es5/utils/encoding/base64EncodeURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function base64EncodeURL(sourceUrl) {
// ignore errors
}
sourceUrl = encodeURI(sourceUrl);
return base64Encode(sourceUrl);
return base64Encode(sourceUrl).replace(/\+/g, '-') // Convert '+' to '-'
.replace(/\//g, '_') // Convert '/' to '_'
.replace(/=+$/, ''); // Remove ending '=';
}

module.exports.base64EncodeURL = base64EncodeURL;
5 changes: 2 additions & 3 deletions lib-es5/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ function process_custom_function(customFunction) {
return customFunction;
}
if (customFunction.function_type === "remote") {
var encodedSource = base64EncodeURL(customFunction.source).replace(/\+/g, '-') // Convert '+' to '-'
.replace(/\//g, '_') // Convert '/' to '_'
.replace(/=+$/, ''); // Remove ending '='
var encodedSource = base64EncodeURL(customFunction.source);

return [customFunction.function_type, encodedSource].join(":");
}
return [customFunction.function_type, customFunction.source].join(":");
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/encoding/base64EncodeURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ function base64EncodeURL(sourceUrl) {
// ignore errors
}
sourceUrl = encodeURI(sourceUrl);
return base64Encode(sourceUrl);
return base64Encode(sourceUrl)
.replace(/\+/g, '-') // Convert '+' to '-'
.replace(/\//g, '_') // Convert '/' to '_'
.replace(/=+$/, ''); // Remove ending '=';
}


Expand Down
6 changes: 2 additions & 4 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ function process_custom_function(customFunction) {
return customFunction;
}
if (customFunction.function_type === "remote") {
const encodedSource = base64EncodeURL(customFunction.source)
.replace(/\+/g, '-') // Convert '+' to '-'
.replace(/\//g, '_') // Convert '/' to '_'
.replace(/=+$/, ''); // Remove ending '='
const encodedSource = base64EncodeURL(customFunction.source);

return [customFunction.function_type, encodedSource].join(":");
}
return [customFunction.function_type, customFunction.source].join(":");
Expand Down
13 changes: 13 additions & 0 deletions test/integration/api/uploader/uploader_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ describe("uploader", function () {
});
});



it("should successfully override original_filename", function () {
return cloudinary.v2.uploader.upload("http://cloudinary.com/images/old_logo.png", {
filename_override: 'overridden'
Expand All @@ -116,6 +118,17 @@ describe("uploader", function () {
});
});

it('should allow upload with url safe base64 in overlay', function () {
const overlayUrl = 'https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png';
const baseImageUrl ='http://cloudinary.com/images/old_logo.png';

const options = {transformation: {overlay: { url: overlayUrl }}};
return cloudinary.v2.uploader.upload(baseImageUrl, options)
.then((result) => {
expect(result).to.have.key("created_at");
});
});

describe("remote urls ", function () {
const mocked = helper.mockTest();
it("should send s3:// URLs to server", function () {
Expand Down
6 changes: 3 additions & 3 deletions test/utils/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,18 +759,18 @@ describe("utils", function () {
resource_type: "fetch",
url: "http://cloudinary.com/images/old_logo.png"
},
"fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc="
"fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc"
],
[
"fetch remote UTF",
{
url: "https://upload.wikimedia.org/wikipedia/commons/2/2b/고창갯벌.jpg"
},
"fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc="
"fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc"
],
["fetch explicit",
"fetch:http://cloudinary.com/images/old_logo.png",
"fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc="]
"fetch:aHR0cDovL2Nsb3VkaW5hcnkuY29tL2ltYWdlcy9vbGRfbG9nby5wbmc"]
];
[
{
Expand Down