[wp-trac] [WordPress Trac] #44832: Lack of null check in wp-embed.js causes uncaught error to be thrown under certain circumstances.

WordPress Trac noreply at wordpress.org
Fri Sep 7 03:58:15 UTC 2018


#44832: Lack of null check in wp-embed.js causes uncaught error to be thrown under
certain circumstances.
-------------------------------------------------+-------------------------
 Reporter:  dsifford                             |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  4.9.9
Component:  Embeds                               |     Version:  4.4
 Severity:  minor                                |  Resolution:  fixed
 Keywords:  good-first-bug has-patch needs-      |     Focuses:  javascript
  testing fixed-major                            |
-------------------------------------------------+-------------------------

Comment (by ekernercom):

 Better written as follows, so the condition evaluation stops on the first
 false:


 {{{
 if (!data || !data.secret || !data.message || !data.value) {
         return;
 }}}


 Replying to [comment:1 swissspidy]:
 > Good catch! Although your proposed change wouldn't actually return early
 when `data` is null.
 >
 > It would be more something like
 >
 >
 > {{{
 > if ( ! data || ! ( data.secret || data.message || data.value ) ) {
 >       return;
 > }
 > }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44832#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list