SPServices icon indicating copy to clipboard operation
SPServices copied to clipboard

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

Open AKrasheninnikov opened this issue 5 years ago • 1 comments

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 avatar Dec 05 '19 14:12 AKrasheninnikov

2019-12-05 17_54_54-Window

AKrasheninnikov avatar Dec 05 '19 14:12 AKrasheninnikov