Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/10/2014 06:09:14 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Update to newer slashing functions, as our minimum requirement is WordPress 3.6.

Also add filters to topic-title & topic-tags form fields. See #2719.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/extend/akismet.php

    r5466 r5559  
    395395        // Ready...
    396396        foreach ( $post_data as $key => $data ) {
    397             $query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';
     397            $query_string .= $key . '=' . urlencode( wp_unslash( $data ) ) . '&';
    398398        }
    399399
     
    626626
    627627        // Preload required variables
    628         $bbp_version    = bbp_get_version();
    629         $content_length = strlen( $request );
    630         $http_host      = $host;
    631         $blog_charset   = get_option( 'blog_charset' );
    632         $response       = '';
    633         $errno          = null;
    634         $errstr         = null;
     628        $bbp_version  = bbp_get_version();
     629        $http_host    = $host;
     630        $blog_charset = get_option( 'blog_charset' );
     631        $response     = '';
    635632
    636633        // Untque User Agent
     
    643640        }
    644641
    645         // WP HTTP class is available
    646         if ( function_exists( 'wp_remote_post' ) ) {
    647 
    648             // Setup the arguments
    649             $http_args = array(
    650                 'body'             => $request,
    651                 'headers'          => array(
    652                     'Content-Type' => 'application/x-www-form-urlencoded; charset=' . $blog_charset,
    653                     'Host'         => $host,
    654                     'User-Agent'   => $akismet_ua
    655                 ),
    656                 'httpversion'      => '1.0',
    657                 'timeout'          => 15
    658             );
    659 
    660             // Where we are sending our request
    661             $akismet_url = 'http://' . $http_host . $path;
    662 
    663             // Send the request
    664             $response    = wp_remote_post( $akismet_url, $http_args );
    665 
    666             // Bail if the response is an error
    667             if ( is_wp_error( $response ) ) {
    668                 return '';
    669             }
    670 
    671             // No errors so return response
    672             return array( $response['headers'], $response['body'] );
    673 
    674         // WP HTTP class is not available (Why not?)
    675         } else {
    676 
    677             // Header info to use with our socket
    678             $http_request  = "POST {$path} HTTP/1.0\r\n";
    679             $http_request .= "Host: {$host}\r\n";
    680             $http_request .= "Content-Type: application/x-www-form-urlencoded; charset={$blog_charset}\r\n";
    681             $http_request .= "Content-Length: {$content_length}\r\n";
    682             $http_request .= "User-Agent: {$akismet_ua}\r\n";
    683             $http_request .= "\r\n";
    684             $http_request .= $request;
    685 
    686             // Open a socket connection
    687             if ( false !== ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
    688 
    689                 // Write our request to the pointer
    690                 fwrite( $fs, $http_request );
    691 
    692                 // Loop through pointer and compile a response
    693                 while ( !feof( $fs ) ) {
    694                     // One TCP-IP packet at a time
    695                     $response .= fgets( $fs, 1160 );
    696                 }
    697 
    698                 // Close our socket
    699                 fclose( $fs );
    700 
    701                 // Explode the response into usable data
    702                 $response = explode( "\r\n\r\n", $response, 2 );
    703             }
    704 
    705             // Return the response ('' if error/empty)
    706             return $response;
    707         }
     642        // Setup the arguments
     643        $http_args = array(
     644            'body'             => $request,
     645            'headers'          => array(
     646                'Content-Type' => 'application/x-www-form-urlencoded; charset=' . $blog_charset,
     647                'Host'         => $host,
     648                'User-Agent'   => $akismet_ua
     649            ),
     650            'httpversion'      => '1.0',
     651            'timeout'          => 15
     652        );
     653
     654        // Where we are sending our request
     655        $akismet_url = 'http://' . $http_host . $path;
     656
     657        // Send the request
     658        $response    = wp_remote_post( $akismet_url, $http_args );
     659
     660        // Bail if the response is an error
     661        if ( is_wp_error( $response ) ) {
     662            return '';
     663        }
     664
     665        // No errors so return response
     666        return array( $response['headers'], $response['body'] );
    708667    }
    709668
Note: See TracChangeset for help on using the changeset viewer.