diff --git a/samlmetajs/mdreader.js b/samlmetajs/mdreader.js index 5a34fac..93dd5fa 100644 --- a/samlmetajs/mdreader.js +++ b/samlmetajs/mdreader.js @@ -551,7 +551,6 @@ isHTTPS = function(string) { parseFromString = function(xmlstring) { - var doc = null; var result = {}; var entitydescriptor = null; @@ -1317,7 +1316,6 @@ parseFromString = function(xmlstring) { if (xmlstring) { try { validateXML(xmlstring); - doc = getDoc(xmlstring); entitydescriptor = parseEntityDescriptor(getDoc(xmlstring)); } catch (e) { console.log(e.message); @@ -1328,24 +1326,30 @@ parseFromString = function(xmlstring) { entitydescriptor = parseEntityDescriptor(getNewDoc()); } - - if (entitydescriptor.name) { - // Everthing is OK with the name. No need to override. - } else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.mdui && entitydescriptor.saml2sp.mdui.name) { - entitydescriptor.name = entitydescriptor.saml2sp.mdui.name; - } else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.acs && entitydescriptor.saml2sp.acs.name) { - entitydescriptor.name = entitydescriptor.saml2sp.acs.name; + if (!entitydescriptor.name) { + if (entitydescriptor.hasMDUIProperty('name')) { + mduiAux = entitydescriptor.getProperty('mdui'); + entitydescriptor.name = mduiAux.name; + } else if (entitydescriptor.hasProperty('acs')) { + mduiAux = entitydescriptor.getProperty('acs'); + if (hasProp(mduiAux, 'name')) { + entitydescriptor.name = mduiAux.name; + } + } } - if (entitydescriptor.descr) { - // Everthing is OK with the name. No need to override. - } else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.mdui && entitydescriptor.saml2sp.mdui.descr) { - entitydescriptor.descr = entitydescriptor.saml2sp.mdui.descr; - } else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.acs && entitydescriptor.saml2sp.acs.descr) { - entitydescriptor.descr = entitydescriptor.saml2sp.acs.descr; + if (!entitydescriptor.descr) { + if (entitydescriptor.hasMDUIProperty('descr')) { + mduiAux = entitydescriptor.getProperty('mdui'); + entitydescriptor.descr = mduiAux.descr; + } else if (entitydescriptor.hasProperty('acs')) { + mduiAux = entitydescriptor.getProperty('acs'); + if (hasProp(mduiAux, 'descr')) { + entitydescriptor.descr = mduiAux.descr; + } + } } - if (!entitydescriptor.name) { processTest(new TestResult('noentityname', 'The entity did not include a name', 0, 1)); } diff --git a/samlmetajs/samlmeta.plugin.info.js b/samlmetajs/samlmeta.plugin.info.js index 007a56f..3a634fb 100644 --- a/samlmetajs/samlmeta.plugin.info.js +++ b/samlmetajs/samlmeta.plugin.info.js @@ -324,7 +324,12 @@ }, fromXML: function (entitydescriptor) { - var l; + var entityNode = entitydescriptor.saml2sp, + l; + + if (entityNode === undefined) { + entityNode = entitydescriptor.saml2idp; + } UI.clearInfoname(); if (entitydescriptor.name) { @@ -346,36 +351,36 @@ UI.clearInfologo(); if (entitydescriptor.hasLogo()) { - for (l in entitydescriptor.saml2sp.mdui.logo) { - if (entitydescriptor.saml2sp.mdui.logo.hasOwnProperty(l)) { - UI.addInfologo(l, entitydescriptor.saml2sp.mdui.logo[l]); + for (l in entityNode.mdui.logo) { + if (entityNode.mdui.logo.hasOwnProperty(l)) { + UI.addInfologo(l, entityNode.mdui.logo[l]); } } } UI.clearInfokeywords(); if (entitydescriptor.hasKeywords()) { - for (l in entitydescriptor.saml2sp.mdui.keywords) { - if (entitydescriptor.saml2sp.mdui.keywords.hasOwnProperty(l)) { - UI.addInfokeywords(l, entitydescriptor.saml2sp.mdui.keywords[l]); + for (l in entityNode.mdui.keywords) { + if (entityNode.mdui.keywords.hasOwnProperty(l)) { + UI.addInfokeywords(l, entityNode.mdui.keywords[l]); } } } UI.clearInformationURL(); if (entitydescriptor.hasInformationURL()) { - for (l in entitydescriptor.saml2sp.mdui.informationURL) { - if (entitydescriptor.saml2sp.mdui.informationURL.hasOwnProperty(l)) { - UI.addInformationURL(l, entitydescriptor.saml2sp.mdui.informationURL[l]); + for (l in entityNode.mdui.informationURL) { + if (entityNode.mdui.informationURL.hasOwnProperty(l)) { + UI.addInformationURL(l, entityNode.mdui.informationURL[l]); } } } UI.clearPrivacyStatementURL(); if (entitydescriptor.hasPrivacyStatementURL()) { - for (l in entitydescriptor.saml2sp.mdui.privacyStatementURL) { - if (entitydescriptor.saml2sp.mdui.privacyStatementURL.hasOwnProperty(l)) { - UI.addPrivacyStatementURL(l, entitydescriptor.saml2sp.mdui.privacyStatementURL[l]); + for (l in entityNode.mdui.privacyStatementURL) { + if (entityNode.mdui.privacyStatementURL.hasOwnProperty(l)) { + UI.addPrivacyStatementURL(l, entityNode.mdui.privacyStatementURL[l]); } } } diff --git a/samlmetajs/samlmeta.plugin.location.js b/samlmetajs/samlmeta.plugin.location.js index e7c5553..b95c2dd 100644 --- a/samlmetajs/samlmeta.plugin.location.js +++ b/samlmetajs/samlmeta.plugin.location.js @@ -121,10 +121,20 @@ if (entitydescriptor.hasLocation()) { location = entitydescriptor.getLocation(); - UI.setLocation(location); spl = location.split(','); + if (spl.length !== 2) { + spl = location.split('/'); + if (spl.length !== 2) { + // Bad location data + return; + } + } latLng = new google.maps.LatLng(spl[0], spl[1]); + location = latLng.toString(); + location = location.substring(1, location.length - 1); + + UI.setLocation(location); map.panTo(latLng); mapmarker.setPosition(latLng); UI.geocodePosition(latLng);