Changeset 9074
- Timestamp:
- 07/24/2019 06:42:12 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/style/trac/trac-security.js
r7901 r9074 4 4 (function($) { 5 5 var propertyform = $( '#propertyform' ), 6 submit = propertyform.find( 'input[type="submit"] ' );6 submit = propertyform.find( 'input[type="submit"][name="submit"]' ); 7 7 8 8 if ( $( document.body ).hasClass( 'security' ) ) { … … 33 33 34 34 return ( overlap.length !== 0 ); 35 }, 36 37 seems_like_pentest : function(str) { 38 return ( 39 str.toLowerCase().indexOf( 'onerror=' ) != -1 40 || 41 str.toLowerCase().indexOf( 'onload=' ) != -1 42 || 43 str.toLowerCase().indexOf( '<script' ) != -1 44 ); 35 45 } 36 46 }; … … 47 57 } else { 48 58 // We need to add the checkbox 49 $( '.buttons' ).before( '<p id="security-question"><label><input type="checkbox" name="sec_question" />' + 59 $( '.buttons' ).before( 60 '<p id="security-question"><label><input type="checkbox" name="sec_question" />' + 50 61 ' I am <strong>not</strong> reporting a security issue</label>' + 51 ' — report <a href="http://make.wordpress.org/core/handbook/reporting-security-vulnerabilities/">security issues</a> to the <a href="https://hackerone.com/wordpress">WordPress HackerOne program</a></p>' ); 62 ' — report <a href="http://make.wordpress.org/core/handbook/reporting-security-vulnerabilities/">security issues</a> to the <a href="https://hackerone.com/wordpress">WordPress HackerOne program</a>' + 63 '</p>' 64 ); 52 65 } 53 66 … … 56 69 function hide_box() { 57 70 submit.prop( 'disabled', false ); 58 $( '#sec_question' ).hide(); 71 // Continue to ask the question, just don't require it to submit the ticket. 72 // $( '#security-question' ).hide(); 59 73 } 60 74 61 jQuery( '#field-summary, #field-description, #field-keywords' ).on( 'keyup', function() {62 var entry = $ (this).val();75 function check_field_value( $el ) { 76 var entry = $el.val(); 63 77 64 78 if ( wp.trac_security.has_overlap( entry, wp.trac_security.badwords ) ) { 79 show_box(); 80 } else if ( wp.trac_security.seems_like_pentest( entry ) ) { 65 81 show_box(); 66 82 } else { 67 83 hide_box(); 68 84 } 69 }); 85 } 86 87 // Check the field value upon keyup 88 jQuery( '#field-summary, #field-description, #field-keywords' ).on( 'keyup', function() { 89 return check_field_value( $(this) ); 90 } ); 91 92 // Trigger on pageload too, ie. upon Preview 93 jQuery( '#field-summary, #field-description, #field-keywords' ).each( function( i, el ) { 94 var $el = $(el); 95 if ( $el.val() != '' ) { 96 check_field_value( $el ); 97 } 98 } ); 70 99 71 100 propertyform.on( 'change', '#security-question input', function() {
Note: See TracChangeset
for help on using the changeset viewer.