Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

js api: escape & and = in all string config values (#260) #269

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
36 changes: 24 additions & 12 deletions core/src/javascript/flowplayer.js/flowplayer-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,27 @@
to[evt].push(fn);
}

// escape & and = in config written into flashvars (issue #21)
function queryescape(url) {
return url.replace(/&/g, '%26').replace(/&/g, '%26').replace(/=/g, '%3D');
}
// recursively cycle through config objects for queryescaping,
// i.e. escape & and = only (issues #21, #260)
// because & and = cannot be written into the Flash object on the page
function queryescape(obj) {
if (typeof obj === "string") {
return obj.replace(/&(amp;)?/g, '%26').replace(/=/g, '%3D');
} else if (typeof obj === "object") {
if (obj.length) {
each(obj, function (i, item) {
each(item, function (key, val) {
obj[i][key] = queryescape(val);
});
});
} else {
each(obj, function (key, val) {
obj[key] = queryescape(val);
});
}
}
return obj;
}

// generates an unique id
function makeId() {
Expand Down Expand Up @@ -980,10 +997,6 @@ function Player(wrapper, params, conf) {
conf.clip.url = wrapper.getAttribute("href", 2);
}

if (conf.clip.url) {
conf.clip.url = queryescape(conf.clip.url);
}

commonClip = new Clip(conf.clip, -1, self);

// playlist
Expand All @@ -1000,10 +1013,6 @@ function Player(wrapper, params, conf) {
clip = {url: "" + clip};
}

if (clip.url) {
clip.url = queryescape(clip.url);
}

// populate common clip properties to each clip
each(conf.clip, function(key, val) {
if (val !== undefined && clip[key] === undefined && typeof val != 'function') {
Expand Down Expand Up @@ -1038,6 +1047,9 @@ function Player(wrapper, params, conf) {
}
});

// queryescape string values
conf = queryescape(conf);


// plugins
each(conf.plugins, function(name, val) {
Expand Down