Plugin Directory

Changeset 3094654


Ignore:
Timestamp:
05/29/2024 02:15:05 PM (21 months ago)
Author:
wpengine
Message:

Update to version "1.3.1" from GitHub

Location:
faustwp
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • faustwp/tags/"1.3.1"/CHANGELOG.md

    r3086589 r3094654  
    11# Faust
     2
     3## 1.3.1
     4
     5### Patch Changes
     6
     7- c28624c: Improve domain_match function to handle port checks and Add Comprehensive Test Cases
    28
    39## 1.3.0
  • faustwp/tags/"1.3.1"/faustwp.php

    r3086589 r3094654  
    1010 * Text Domain: faustwp
    1111 * Domain Path: /languages
    12  * Version: 1.3.0
     12 * Version: 1.3.1
    1313 * Requires PHP: 7.2
    1414 * Requires at least: 5.7
  • faustwp/tags/"1.3.1"/includes/rest/callbacks.php

    r3062809 r3094654  
    2727use function WPE\FaustWP\Settings\faustwp_update_setting;
    2828use function WPE\FaustWP\Settings\is_telemetry_enabled;
    29 use function WPE\FaustWP\Utilities\domains_match;
     29use function WPE\FaustWP\Utilities\strict_domain_match;
    3030
    3131if ( ! defined( 'ABSPATH' ) ) {
     
    561561
    562562        // Check if the provided WordPress URL does not match the frontend URI.
    563         if ( ! domains_match( $public_wordpress_url, $frontend_uri ) ) {
     563        if ( ! strict_domain_match( $public_wordpress_url, $frontend_uri ) ) {
    564564            // Return 200 OK if the URLs do not match.
    565565            $response = new \WP_REST_Response( 'OK', 200 );
  • faustwp/tags/"1.3.1"/includes/utilities/functions.php

    r3062809 r3094654  
    4646
    4747/**
    48  * Checks if two domain strings represent the same domain.
     48 * Performs a strict domain comparison
     49 * Also checks for matching ports (if present).
    4950 *
    5051 * @param string $domain1 The first domain string.
    5152 * @param string $domain2 The second domain string.
    52  * @return bool True if the domains match, false otherwise.
     53 * @return bool True if the domains match (including localhost, loopback, and ports), false otherwise.
    5354 */
    54 function domains_match( $domain1, $domain2 ) {
    55     // Extract the domain part.
    56     $extract_domain = function ( $url ) {
    57         $parsed_url = wp_parse_url( $url, PHP_URL_HOST );
    58         return $parsed_url ? $parsed_url : null;
    59     };
     55function strict_domain_match( string $domain1, string $domain2 ): bool {
     56    // Parse URLs.
     57    $parsed_domain1 = wp_parse_url( $domain1 );
     58    $parsed_domain2 = wp_parse_url( $domain2 );
    6059
    61     $domain1 = $extract_domain( $domain1 );
    62     $domain2 = $extract_domain( $domain2 );
     60    // Extract components.
     61    $host1   = isset( $parsed_domain1['host'] ) ? $parsed_domain1['host'] : null;
     62    $host2   = isset( $parsed_domain2['host'] ) ? $parsed_domain2['host'] : null;
     63    $scheme1 = isset( $parsed_domain1['scheme'] ) ? $parsed_domain1['scheme'] : 'http';
     64    $scheme2 = isset( $parsed_domain2['scheme'] ) ? $parsed_domain2['scheme'] : 'http';
     65    $port1   = isset( $parsed_domain1['port'] ) ? (int) $parsed_domain1['port'] : ( 'https' === $scheme1 ? 443 : 80 );
     66    $port2   = isset( $parsed_domain2['port'] ) ? (int) $parsed_domain2['port'] : ( 'https' === $scheme2 ? 443 : 80 );
    6367
    64     // Remove "www" prefix from domain if present.
    65     $domain1 = preg_replace( '/^www\./i', '', $domain1 );
    66     $domain2 = preg_replace( '/^www\./i', '', $domain2 );
     68    if ( empty( $host1 ) || empty( $host2 ) ) {
     69        return false;
     70    }
    6771
    68     return null !== $domain1 && null !== $domain2 && $domain1 === $domain2;
     72    // Normalize the hosts by removing 'www.' if present.
     73    $normalized_host1 = preg_replace( '/^www\./', '', $host1 );
     74    $normalized_host2 = preg_replace( '/^www\./', '', $host2 );
     75
     76    return ( $normalized_host1 === $normalized_host2 ) && ( $scheme1 === $scheme2 ) && ( $port1 === $port2 );
    6977}
  • faustwp/tags/"1.3.1"/readme.txt

    r3086589 r3094654  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 1.3.0
     6Stable tag: 1.3.1
    77Requires PHP: 7.2
    88License: GPLv2 or later
     
    5555== Changelog ==
    5656
     57= 1.3.1 =
     58
     59### Patch Changes
     60
     61- c28624c: Improve domain_match function to handle port checks and Add Comprehensive Test Cases
     62
    5763= 1.3.0 =
    5864
     
    7177- 4724719: Faust now errors if the NEXT_PUBLIC_WORDPRESS_URL matches the Headless URL in Faust Plugin settings.
    7278
    73 = 1.2.2 =
    74 
    75 ### Patch Changes
    76 
    77 - 47f6bd0: Faust now warns you if the secret key in your environment is invalid or incorrect.
    78 
    7979[View the full changelog](https://github.com/wpengine/faustjs/blob/canary/plugins/faustwp/CHANGELOG.md)
  • faustwp/trunk/CHANGELOG.md

    r3086589 r3094654  
    11# Faust
     2
     3## 1.3.1
     4
     5### Patch Changes
     6
     7- c28624c: Improve domain_match function to handle port checks and Add Comprehensive Test Cases
    28
    39## 1.3.0
  • faustwp/trunk/faustwp.php

    r3086589 r3094654  
    1010 * Text Domain: faustwp
    1111 * Domain Path: /languages
    12  * Version: 1.3.0
     12 * Version: 1.3.1
    1313 * Requires PHP: 7.2
    1414 * Requires at least: 5.7
  • faustwp/trunk/includes/rest/callbacks.php

    r3062809 r3094654  
    2727use function WPE\FaustWP\Settings\faustwp_update_setting;
    2828use function WPE\FaustWP\Settings\is_telemetry_enabled;
    29 use function WPE\FaustWP\Utilities\domains_match;
     29use function WPE\FaustWP\Utilities\strict_domain_match;
    3030
    3131if ( ! defined( 'ABSPATH' ) ) {
     
    561561
    562562        // Check if the provided WordPress URL does not match the frontend URI.
    563         if ( ! domains_match( $public_wordpress_url, $frontend_uri ) ) {
     563        if ( ! strict_domain_match( $public_wordpress_url, $frontend_uri ) ) {
    564564            // Return 200 OK if the URLs do not match.
    565565            $response = new \WP_REST_Response( 'OK', 200 );
  • faustwp/trunk/includes/utilities/functions.php

    r3062809 r3094654  
    4646
    4747/**
    48  * Checks if two domain strings represent the same domain.
     48 * Performs a strict domain comparison
     49 * Also checks for matching ports (if present).
    4950 *
    5051 * @param string $domain1 The first domain string.
    5152 * @param string $domain2 The second domain string.
    52  * @return bool True if the domains match, false otherwise.
     53 * @return bool True if the domains match (including localhost, loopback, and ports), false otherwise.
    5354 */
    54 function domains_match( $domain1, $domain2 ) {
    55     // Extract the domain part.
    56     $extract_domain = function ( $url ) {
    57         $parsed_url = wp_parse_url( $url, PHP_URL_HOST );
    58         return $parsed_url ? $parsed_url : null;
    59     };
     55function strict_domain_match( string $domain1, string $domain2 ): bool {
     56    // Parse URLs.
     57    $parsed_domain1 = wp_parse_url( $domain1 );
     58    $parsed_domain2 = wp_parse_url( $domain2 );
    6059
    61     $domain1 = $extract_domain( $domain1 );
    62     $domain2 = $extract_domain( $domain2 );
     60    // Extract components.
     61    $host1   = isset( $parsed_domain1['host'] ) ? $parsed_domain1['host'] : null;
     62    $host2   = isset( $parsed_domain2['host'] ) ? $parsed_domain2['host'] : null;
     63    $scheme1 = isset( $parsed_domain1['scheme'] ) ? $parsed_domain1['scheme'] : 'http';
     64    $scheme2 = isset( $parsed_domain2['scheme'] ) ? $parsed_domain2['scheme'] : 'http';
     65    $port1   = isset( $parsed_domain1['port'] ) ? (int) $parsed_domain1['port'] : ( 'https' === $scheme1 ? 443 : 80 );
     66    $port2   = isset( $parsed_domain2['port'] ) ? (int) $parsed_domain2['port'] : ( 'https' === $scheme2 ? 443 : 80 );
    6367
    64     // Remove "www" prefix from domain if present.
    65     $domain1 = preg_replace( '/^www\./i', '', $domain1 );
    66     $domain2 = preg_replace( '/^www\./i', '', $domain2 );
     68    if ( empty( $host1 ) || empty( $host2 ) ) {
     69        return false;
     70    }
    6771
    68     return null !== $domain1 && null !== $domain2 && $domain1 === $domain2;
     72    // Normalize the hosts by removing 'www.' if present.
     73    $normalized_host1 = preg_replace( '/^www\./', '', $host1 );
     74    $normalized_host2 = preg_replace( '/^www\./', '', $host2 );
     75
     76    return ( $normalized_host1 === $normalized_host2 ) && ( $scheme1 === $scheme2 ) && ( $port1 === $port2 );
    6977}
  • faustwp/trunk/readme.txt

    r3086589 r3094654  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 1.3.0
     6Stable tag: 1.3.1
    77Requires PHP: 7.2
    88License: GPLv2 or later
     
    5555== Changelog ==
    5656
     57= 1.3.1 =
     58
     59### Patch Changes
     60
     61- c28624c: Improve domain_match function to handle port checks and Add Comprehensive Test Cases
     62
    5763= 1.3.0 =
    5864
     
    7177- 4724719: Faust now errors if the NEXT_PUBLIC_WORDPRESS_URL matches the Headless URL in Faust Plugin settings.
    7278
    73 = 1.2.2 =
    74 
    75 ### Patch Changes
    76 
    77 - 47f6bd0: Faust now warns you if the secret key in your environment is invalid or incorrect.
    78 
    7979[View the full changelog](https://github.com/wpengine/faustjs/blob/canary/plugins/faustwp/CHANGELOG.md)
Note: See TracChangeset for help on using the changeset viewer.