Changeset 3094654
- Timestamp:
- 05/29/2024 02:15:05 PM (21 months ago)
- Location:
- faustwp
- Files:
-
- 10 edited
- 1 copied
-
tags/"1.3.1" (copied) (copied from faustwp/trunk)
-
tags/"1.3.1"/CHANGELOG.md (modified) (1 diff)
-
tags/"1.3.1"/faustwp.php (modified) (1 diff)
-
tags/"1.3.1"/includes/rest/callbacks.php (modified) (2 diffs)
-
tags/"1.3.1"/includes/utilities/functions.php (modified) (1 diff)
-
tags/"1.3.1"/readme.txt (modified) (3 diffs)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/faustwp.php (modified) (1 diff)
-
trunk/includes/rest/callbacks.php (modified) (2 diffs)
-
trunk/includes/utilities/functions.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
faustwp/tags/"1.3.1"/CHANGELOG.md
r3086589 r3094654 1 1 # 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 2 8 3 9 ## 1.3.0 -
faustwp/tags/"1.3.1"/faustwp.php
r3086589 r3094654 10 10 * Text Domain: faustwp 11 11 * Domain Path: /languages 12 * Version: 1.3. 012 * Version: 1.3.1 13 13 * Requires PHP: 7.2 14 14 * Requires at least: 5.7 -
faustwp/tags/"1.3.1"/includes/rest/callbacks.php
r3062809 r3094654 27 27 use function WPE\FaustWP\Settings\faustwp_update_setting; 28 28 use function WPE\FaustWP\Settings\is_telemetry_enabled; 29 use function WPE\FaustWP\Utilities\ domains_match;29 use function WPE\FaustWP\Utilities\strict_domain_match; 30 30 31 31 if ( ! defined( 'ABSPATH' ) ) { … … 561 561 562 562 // 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 ) ) { 564 564 // Return 200 OK if the URLs do not match. 565 565 $response = new \WP_REST_Response( 'OK', 200 ); -
faustwp/tags/"1.3.1"/includes/utilities/functions.php
r3062809 r3094654 46 46 47 47 /** 48 * Checks if two domain strings represent the same domain. 48 * Performs a strict domain comparison 49 * Also checks for matching ports (if present). 49 50 * 50 51 * @param string $domain1 The first domain string. 51 52 * @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. 53 54 */ 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 }; 55 function 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 ); 60 59 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 ); 63 67 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 } 67 71 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 ); 69 77 } -
faustwp/tags/"1.3.1"/readme.txt
r3086589 r3094654 4 4 Requires at least: 5.7 5 5 Tested up to: 6.5 6 Stable tag: 1.3. 06 Stable tag: 1.3.1 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later … … 55 55 == Changelog == 56 56 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 57 63 = 1.3.0 = 58 64 … … 71 77 - 4724719: Faust now errors if the NEXT_PUBLIC_WORDPRESS_URL matches the Headless URL in Faust Plugin settings. 72 78 73 = 1.2.2 =74 75 ### Patch Changes76 77 - 47f6bd0: Faust now warns you if the secret key in your environment is invalid or incorrect.78 79 79 [View the full changelog](https://github.com/wpengine/faustjs/blob/canary/plugins/faustwp/CHANGELOG.md) -
faustwp/trunk/CHANGELOG.md
r3086589 r3094654 1 1 # 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 2 8 3 9 ## 1.3.0 -
faustwp/trunk/faustwp.php
r3086589 r3094654 10 10 * Text Domain: faustwp 11 11 * Domain Path: /languages 12 * Version: 1.3. 012 * Version: 1.3.1 13 13 * Requires PHP: 7.2 14 14 * Requires at least: 5.7 -
faustwp/trunk/includes/rest/callbacks.php
r3062809 r3094654 27 27 use function WPE\FaustWP\Settings\faustwp_update_setting; 28 28 use function WPE\FaustWP\Settings\is_telemetry_enabled; 29 use function WPE\FaustWP\Utilities\ domains_match;29 use function WPE\FaustWP\Utilities\strict_domain_match; 30 30 31 31 if ( ! defined( 'ABSPATH' ) ) { … … 561 561 562 562 // 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 ) ) { 564 564 // Return 200 OK if the URLs do not match. 565 565 $response = new \WP_REST_Response( 'OK', 200 ); -
faustwp/trunk/includes/utilities/functions.php
r3062809 r3094654 46 46 47 47 /** 48 * Checks if two domain strings represent the same domain. 48 * Performs a strict domain comparison 49 * Also checks for matching ports (if present). 49 50 * 50 51 * @param string $domain1 The first domain string. 51 52 * @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. 53 54 */ 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 }; 55 function 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 ); 60 59 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 ); 63 67 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 } 67 71 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 ); 69 77 } -
faustwp/trunk/readme.txt
r3086589 r3094654 4 4 Requires at least: 5.7 5 5 Tested up to: 6.5 6 Stable tag: 1.3. 06 Stable tag: 1.3.1 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later … … 55 55 == Changelog == 56 56 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 57 63 = 1.3.0 = 58 64 … … 71 77 - 4724719: Faust now errors if the NEXT_PUBLIC_WORDPRESS_URL matches the Headless URL in Faust Plugin settings. 72 78 73 = 1.2.2 =74 75 ### Patch Changes76 77 - 47f6bd0: Faust now warns you if the secret key in your environment is invalid or incorrect.78 79 79 [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.