Opened 8 years ago
Closed 8 years ago
#44832 closed defect (bug) (fixed)
Lack of null check in wp-embed.js causes uncaught error to be thrown under certain circumstances.
| Reported by: | dsifford | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9.9 |
| Component: | Embeds | Version: | 4.4 |
| Severity: | minor | Keywords: | good-first-bug has-patch needs-testing |
| Cc: | Focuses: | javascript |
Description
The file and lines in question can be seen here: https://github.com/WordPress/WordPress/blob/5bbb3b38d96eb0aac29d3b368d541039a3b1fbb8/wp-includes/js/wp-embed.js#L31-L33
The issue specifically is that currently the script assumes there will always be a data parameter on message. This is not true in the case of Google ReCAPTCHA (and I assume many other 3rd party scripts).
In these cases, data is null and when attempting to access properties on null, an error is thrown.
This all can be fixed by changing the if statement from what it is currently to:
if ( data && ! ( data.secret || data.message || data.value ) ) {
return;
}
Attachments (2)
Change History (17)
#1
follow-up:
↓ 12
@
8 years ago
- Keywords needs-patch good-first-bug added
- Milestone Awaiting Review → Future Release
- Severity normal → minor
- Version trunk → 4.4
#3
@
8 years ago
- Milestone Future Release → 4.9.9
Just stumbled upon this while setting up reCAPTCHA. Moving to 4.9.9 for visibility.
#7
@
8 years ago
- Keywords fixed-major added
- Resolution fixed
- Status closed → reopened
Reopening for 4.9.9 consideration.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Good catch! Although your proposed change wouldn't actually return early when
datais null.It would be more something like
if ( ! data || ! ( data.secret || data.message || data.value ) ) { return; }