Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve escaping of dynamic JavaScript #946

Open
natebot opened this issue Jul 28, 2022 · 0 comments
Open

Improve escaping of dynamic JavaScript #946

natebot opened this issue Jul 28, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@natebot
Copy link

natebot commented Jul 28, 2022

Consider replacing the uses of esc_js() in the output of JS variable names and values coming from PHP.

var <?php echo esc_js( $apple_editor_name ); ?> = ace.edit( '<?php echo esc_js( $apple_editor_name ); ?>' );
jQuery( function() {
jQuery( '#<?php echo esc_js( $apple_field_name ); ?>' ).hide();
<?php echo esc_js( $apple_editor_name ); ?>.setTheme( '<?php echo esc_js( $apple_ace_theme ); ?>' );
<?php echo esc_js( $apple_editor_name ); ?>.getSession().setMode( 'ace/mode/json' );
<?php echo esc_js( $apple_editor_name ); ?>.getSession().setTabSize( 2 );
<?php echo esc_js( $apple_editor_name ); ?>.getSession().setUseSoftTabs( false );
<?php echo esc_js( $apple_editor_name ); ?>.setReadOnly( false );
<?php echo esc_js( $apple_editor_name ); ?>.getSession().setUseWrapMode( true );
<?php echo esc_js( $apple_editor_name ); ?>.getSession().setValue( jQuery( '#<?php echo esc_js( $apple_field_name ); ?>' ).val() );
<?php echo esc_js( $apple_editor_name ); ?>.getSession().on( 'change', function() {
jQuery( '#<?php echo esc_js( $apple_field_name ); ?>' ).val( <?php echo esc_js( $apple_editor_name ); ?>.getSession().getValue() );
} );

@kevinfodness kevinfodness added the enhancement New feature or request label Aug 18, 2022
@kevinfodness kevinfodness added this to the v2.4.0 milestone Oct 5, 2022
@kevinfodness kevinfodness removed this from the v2.4.0 milestone Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants