• First of all I am sorry if this is the wrong place to post this, this is my first post.

    So I have this strange situation where esc_url doesn’t appear to like a .cloud address, I have written some custom code which pulls an attribute from an order and adds this link to customer-note.php, I am leveraging esc_url.

    echo '<li><strong>' . esc_html( $key ) . ':</strong> <a href="' . esc_url( $value ) . '" target="_blank">' . esc_url( $value ) . '</a></li>';

    This has been working great but yesterday I switched from using .net to a .cloud address and the customer note fails to send without any errors that I can observe… I switch back to a .net address and it works just fine, has anyone seen this before?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Mayur

    (@mayur6740)

    Here are a few points to consider that may help you troubleshoot the problem:

    1. URL Format: Ensure that the .cloud URL is correctly formatted. It should begin with either https:// or https://. If it’s missing the scheme, esc_url() might not process it correctly.Example:phpCopy code$value = 'https://your-domain.cloud'; // Ensure the URL has a scheme
    2. Content Security Policy (CSP): Some hosting environments or browsers may have strict content security policies that restrict certain domains. Check if there are any CSP rules in place that could block the .cloud domain.
    3. SSL Certificate: If your .cloud address uses HTTPS, verify that the SSL certificate is properly installed and valid. An invalid certificate can prevent browsers from allowing links to that domain.
    4. Check Server Logs: Look at your server logs for any error messages or warnings that might provide additional insight into why the note fails to send when using the .cloud address.
    5. Debugging: To troubleshoot further, you can add some debugging output to see exactly what $value contains just before it is processed by esc_url():phpCopy codeerror_log( 'Value before esc_url: ' . $value ); // Check the log for the URL
    6. Cross-Origin Requests: If the URL is being used for an AJAX request or similar, make sure that cross-origin resource sharing (CORS) settings are appropriately configured.
    7. Test with Plain HTML: As a quick test, try replacing esc_url($value) with the URL directly to see if it still works. This can help isolate whether the issue is with esc_url() or something else:phpCopy codeecho '<li><strong>' . esc_html( $key ) . ':</strong> <a href="' . $value . '" target="_blank">' . $value . '</a></li>';
    Thread Starter vmanch

    (@vmanch)

    Hello Mayur,

    Thanks for the reply,

    1). I can confirm that the format is the same, I simply change the url from .net to .cloud and the mail never arrives.

    2). Thanks I will have a look at this.

    3). My server’s domain is not using .cloud I am using .ch, esc_url( $value ) is just just something custom I have added into woocommerce customer-note.php and it simply contains .cloud if I change it back to .net the email sends just fine.

    For example if shorturl is .net it works just fine

    ? QRCode: ………………
    ? ShortUrl: https://p.simulator.net/8324343

    if shorturl is .cloud it fails.

    ? QRCode: ……………..
    ? ShortUrl: https://p.simulator.cloud/8324343

    4). No errors unfortunately.

    5). I will try the debugging option

    6). Not the case.

    7). Already tried and it doesn’t work

    Thanks again!

    threadi

    (@threadi)

    I am still trying to understand the specific problem. Which value is actually passed to esc_url()? What is what should come out and what comes out?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.