Making WordPress.org

Changeset 6479


Ignore:
Timestamp:
01/30/2018 11:30:30 PM (9 years ago)
Author:
obenland
Message:

Plugins: Encode readme data before submitting it

Props benlk.
Fixes #3230.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-readme-validator.php

    r6287 r6479  
    3434
    3535                        <p><?php _e( '... or paste your <code>readme.txt</code> here:', 'wporg-plugins' ); ?></p>
    36                         <form method="post" action="">
    37                                 <textarea rows="20" cols="100" name="readme_contents" placeholder="=== Plugin Name ===">
     36                                <textarea rows="20" cols="100" name="readme_visible" placeholder="=== Plugin Name ===">
    3837                                        <?php
    3938                                        if ( isset( $_POST['readme_contents'] ) ) {
    40                                                 echo esc_textarea( wp_unslash( $_POST['readme_contents'] ) );
     39                                                echo esc_textarea( base64_decode( wp_unslash( $_POST['readme_contents'] ) ) );
    4140                                        }
    4241                                        ?>
    4342                                </textarea>
     43                                <form id="readme-data" method="post" action="">
     44                                        <textarea class="screen-reader-text" rows="20" cols="100" name="readme_contents">
     45                                                <?php
     46                                                if ( isset( $_POST['readme_contents'] ) ) {
     47                                                        echo esc_textarea( base64_decode( wp_unslash( $_POST['readme_contents'] ) ) );
     48                                                }
     49                                                ?>
     50                                        </textarea>
    4451                                <p><input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" /></p>
    4552                        </form>
     53                        <script>
     54                                document.getElementById( 'readme-data' ).addEventListener( 'submit', function() {
     55                                        var readmeInputs = document.getElementsByTagName( 'textarea' );
     56
     57                                        readmeInputs[1].value = window.btoa( readmeInputs[0].value );
     58
     59                                        return true;
     60                                } );
     61                        </script>
    4662                </div>
    4763                <?php
    … …  
    5672
    5773                } elseif ( ! empty( $_POST['readme_contents'] ) ) {
    58                         $errors = Validator::instance()->validate_content( wp_unslash( $_REQUEST['readme_contents'] ) );
     74                        $errors = Validator::instance()->validate_content( base64_decode( wp_unslash( $_REQUEST['readme_contents'] ) ) );
    5975
    6076                } else {
Note: See TracChangeset for help on using the changeset viewer.