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

Commit

Permalink
Issue 66: flashVars are not escaped (urlencoded) properly
Browse files Browse the repository at this point in the history
http://code.google.com/p/swfobject/issues/detail?id=66

Added a new swfobject.enableUriEncoding() method that optionally turns on encodeURIComponent for FlashVars.

Signed-off-by: Philip Hutchison <philip@pipwerks.com>
  • Loading branch information
pipwerks committed May 30, 2011
1 parent 79d2aca commit 899ba66
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions swfobject/src/swfobject.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var swfobject = function() {
dynamicStylesheet,
dynamicStylesheetMedia,
autoHideShow = true,
encodeURI_enabled = false,

/* Centralized function for browser feature detection
- User agent string detection is only used when no good alternative is possible
Expand Down Expand Up @@ -713,12 +714,17 @@ var swfobject = function() {
if (flashvarsObj && typeof flashvarsObj === OBJECT) {
for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
if(flashvarsObj.hasOwnProperty(k)){

var key = (encodeURI_enabled) ? encodeURIComponent(k) : k,
value = (encodeURI_enabled) ? encodeURIComponent(flashvarsObj[k]) : flashvarsObj[k];

if (typeof par.flashvars != UNDEF) {
par.flashvars += "&" + k + "=" + flashvarsObj[k];
par.flashvars += "&" + key + "=" + value;
}
else {
par.flashvars = k + "=" + flashvarsObj[k];
par.flashvars = key + "=" + value;
}

}
}
}
Expand Down Expand Up @@ -749,6 +755,10 @@ var swfobject = function() {
autoHideShow = false;
},

enableUriEncoding: function (bool) {
encodeURI_enabled = (typeof bool === UNDEF) ? true : bool;
},

ua: ua,

getFlashPlayerVersion: function() {
Expand Down

0 comments on commit 899ba66

Please sign in to comment.