Now that zmError/zmFatal/zmPanic no longer shadow the native Error
constructor, build a real Error from the message and report its stack
via logReport. This records where the log call originated instead of
just the bare message. An Error passed in directly is used as-is.
The console output and alert() behaviour are unchanged.
The JS logger defined seven global functions with very common names:
Panic, Fatal, Error, Warning, Info, Debug and Dump. The Error() one
shadowed the native window.Error constructor, so every `new Error()`
in the bundled third-party libraries (hls.js, jquery, moment,
bootstrap, ...) was silently hijacked once logger.js loaded. The rest
polluted the global namespace and could collide with plugins.
Rename the definitions to zmPanic, zmFatal, zmError, zmWarning, zmInfo,
zmDebug and zmDump, and update the only ZM call sites (all calls to the
former Error()): montage_common.js, event.js and skin.js. Native
`new Error()`, `throw Error()` and `reject(Error())` uses are left
untouched. No back-compat alias for Error() is added because that would
reintroduce the shadowing bug.
#4914 unconditionally drops Javascript errors and CSP violations sourced from
browser extensions. Some operators want to know when a plugin is touching the
ZoneMinder tab, so gate the suppression behind a config entry.
Add ZM_LOG_BROWSER_EXTENSIONS (boolean, default no) in the logging category.
It is exposed to JS by the existing non-private-config loop in skin.js.php as
the string '0'/'1' (the same convention as ZM_LOG_INJECT), so logger.js only
filters extension sources when it is '0'. Default behaviour is unchanged:
extension noise stays out of the log.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The client-side logger reported every window.onerror and
securitypolicyviolation event, including ones injected by browser
extensions (ad blockers, password managers, etc.). Those fire on every
page, are not ZoneMinder's code, and spam the web_js log with entries
like "inline violated CSP script-src at moz-extension line 46".
Ignore reports whose source is a browser extension
(moz-extension/chrome-extension/safari-web-extension/webkit-masked-url),
checking both the error/source URL and the CSP sourceFile/blockedURI.
Legitimate same-origin errors and CSP violations are still logged.
fixes#3340
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The catch block for the strict-mode arguments.callee TypeError
doesn't need the exception object since the failure is expected.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
window.onerror now captures column number and error stack trace when
available. Undefined or browser-sanitized "Script error." messages get a
descriptive placeholder instead of logging "undefined". Caller name
introspection is guarded against strict mode and empty names.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add eslint to travis.yml
* Update eslint package versions and apply new indent rules
* Enable the brace-style and block-style eslint rules
* Enable the 'curly' eslint rule
* Enable the 'keyword-spacing' eslint rule
* Enable the 'key-spacing' eslint rule
* Enable the 'object-curly-spacing' eslint rule
* Enable the 'no-new-object' eslint rule
* Only disable the no-caller eslint rule in the one affected file
* Enable the 'no-unused-vars' eslint rule for local variables
* Add linting of JS in .php files