Skip to content

Commit

Permalink
since we check attributes for bad values explicitly, don't need the r…
Browse files Browse the repository at this point in the history
…egex on value check any longer. it was too aggressive and was stripping out attributes containing those values even partially
  • Loading branch information
Aeon committed Sep 16, 2011
1 parent 9fe51b4 commit 5039f49
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/core.js
Expand Up @@ -674,7 +674,7 @@ Strophe = {
{
attribute = Strophe.XHTML.attributes[tag][i];
value = elem.getAttribute(attribute);
if(value === null || value === '' || value === false || value === 0)
if(typeof value == 'undefined' || value === null || value === '' || value === false || value === 0)
{
continue;
}
Expand All @@ -685,34 +685,31 @@ Strophe = {
value = value.cssText; // we're dealing with IE, need to get CSS out
}
}
if(!value.match(/0|null|undefined|false/))
// filter out invalid css styles
if(attribute == 'style')
{
// filter out invalid css styles
if(attribute == 'style')
css = [];
cssAttrs = value.split(';');
for(j = 0; j < cssAttrs.length; j++)
{
css = [];
cssAttrs = value.split(';');
for(j = 0; j < cssAttrs.length; j++)
attr = cssAttrs[j].split(':');
cssName = attr[0].replace(/^\s*/, "").replace(/\s*$/, "").toLowerCase();
if(Strophe.XHTML.validCSS(cssName))
{
attr = cssAttrs[j].split(':');
cssName = attr[0].replace(/^\s*/, "").replace(/\s*$/, "").toLowerCase();
if(Strophe.XHTML.validCSS(cssName))
{
cssValue = attr[1].replace(/^\s*/, "").replace(/\s*$/, "");
css.push(cssName + ': ' + cssValue);
}
}
if(css.length > 0)
{
value = css.join('; ');
el.setAttribute(attribute, value);
cssValue = attr[1].replace(/^\s*/, "").replace(/\s*$/, "");
css.push(cssName + ': ' + cssValue);
}
}
else
if(css.length > 0)
{
value = css.join('; ');
el.setAttribute(attribute, value);
}
}
else
{
el.setAttribute(attribute, value);
}
}

for (i = 0; i < elem.childNodes.length; i++) {
Expand Down

0 comments on commit 5039f49

Please sign in to comment.