sympmarc / SPServices

SPServices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.
MIT License
208 stars 61 forks source link

Should check scriptSrc for undefined along with null here. Otherwise SPScriptAudit breaks down. #82

Open AKrasheninnikov opened 4 years ago

AKrasheninnikov commented 4 years ago

https://github.com/sympmarc/SPServices/blob/7ff0d24658d1d354a937bc82ab21cb6352025ea3/src/value-added/SPScriptAudit.js#L206

The hyperlink referenced line checks scriptSrc variable to be not equal to null, but when it's undefined, it's not exactly null, and scriptSrc.length throws an Exception:

jquery.min.js:formatted:3981 Uncaught TypeError: Cannot read property 'length' of undefined
    at Object.success (jquery.SPServices-2014.02.js?_=1575556158629:3117)
    at j (jquery.min.js:formatted:1341)
    at Object.fireWith [as resolveWith] (jquery.min.js:formatted:1398)
    at x (jquery.min.js:formatted:4008)
    at b (jquery.min.js:formatted:4209)
    at Object.send (jquery.min.js:formatted:4212)
    at Function.ajax (jquery.min.js:formatted:3978)
    at SPScriptAuditPage (jquery.SPServices-2014.02.js?_=1575556158629:3104)
    at Element.<anonymous> (jquery.SPServices-2014.02.js?_=1575556158629:3081)
    at Function.each (jquery.min.js:formatted:167)

Encountered when calling

$().SPServices.SPScriptAudit({
auditForms:false, auditViews:false, outputId: "js-output", listName:'layout', showSrc:true
});

and a page such as PageNotFoundError.aspx contains an inline script without src.

AKrasheninnikov commented 4 years ago

2019-12-05 17_54_54-Window