Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    URLs are run through sanitizing and escaping functions for security purposes, and that filters out invalid UTF-8 characters. For your use case, you may need to use custom sanitizing and escaping. See our documentation here. Let me know if it gives you any trouble!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Oh! Another thought, try enabling the new cache compatibility mode for that form tag. It bypasses the PHP filters because it uses JavaScript to get the URL.

    Thread Starter doranan1234

    (@doranan1234)

    Hi,

    Thanks for the soluions.

    For custom sanitizing?and?escaping, May I know how to use that script with this use case?

    For enabling the?new cache compatibility mode, I added dtx_pageload to hidden field but it does not work.

    Could you please advice?

    Thanks,

    Nan

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Can you show me what the form tag looks like in the form editor?

    And can you also confirm you’re using the latest version of the plugin? I’m about to release a fix for another user so if automatic updates are enabled for you, you should get it too (though it doesn’t address your issue so it’ll still likely persist).

    I’ll whip up some code for you after that ??

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    After playing around in my test environment, I think this will work for you. Just copy/paste this into your active theme’s functions.php file.

    /**
     * Maybe Decode Non UTF8 Characters before DTX Sanitize
     *
     * @param string $value value to be sanitized
     * @param string $type Optional. The type of sanitation to return. Default is auto where automatic identification will be used to attempt to identify URLs and email addresses vs text.
     *
     * @return string the modified value
     */
    function custom_dtx_decode_sanitize($value = '', $type = 'auto')
    {
        if ($type == 'text' || $type == 'auto' && is_string($value) && !empty($value = trim($value)) && wp_check_invalid_utf8($value)) {
            return rawurldecode($value);
        }
        return $value;
    }
    add_filter('wpcf7dtx_sanitize', 'custom_dtx_decode_sanitize', 9, 2);

    This code taps into the DTX sanitizing filter before it runs and it checks for any that are being sanitized as text (or auto-identified) and does an extra check for any invalid UTF-8 characters. If the value has invalid UTF-8 characters like in your URL, then it runs a PHP function to decode it so the characters are preserved and not eliminated when sanitizing and escaping happens.

    I decided not to add this to CF7 as a built-in piece because I have no idea what the effects could be for other users. I feel like it’d break a lot of stuff in emails since it’d modify how some things are saved in the database. But for your use-case, since you’re using it for one field, it should be fine. Just be sure you’re using version 3.3.0 of Contact Form 7 – Dynamic Text Extension or later so the filter feature exists!

    The dtx_pageload feature was added earlier this week (3.5.0+), which is the reason why I asked about the version in my previous post. If using an older version, it’d just be ignored.

    Thread Starter doranan1234

    (@doranan1234)

    Hi,

    sorry for late replied.

    Many thanks for helping this and provided the custom script!

    I’ve already updated plugin to latest version but it still does not work.

    Do you have another idea?

    Thanks,

    Nan

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    I took another look at your webpage (https://th.heroleads.asia/blog/??????-growth-marketing-????????????/) and the field value appears to be working as intended by me, but probably not what you prefer.

    It no longer strips out your invalid characters:

    https://th.heroleads.asia/blog/-growth-marketing-/

    But converts them using UTF-8 encoding:

    https://th.heroleads.asia/blog/%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81-growth-marketing-%E0%B9%80%E0%B8%97%E0%B8%A3%E0%B8%99%E0%B8%94%E0%B9%8C%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%A5%E0%B8%B2/

    It certainly looks messy, but the URL still works if you copy/paste that encoded URL into the browser. You can also test by clicking the links below, they should both take you to the same page:

    Since your webpage is set to be indexed by search engines, I would encourage you to change the URL so that all characters are ASCII characters. This is recommended by Google under their URL structure best practices. Following best practices may improve your rankings for those search engines.

    Cheers!

    Thread Starter doranan1234

    (@doranan1234)

    Understood and many thanks for your fully help.

    Have a great day!

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Not a problem! Glad I could help. Good luck with your business! ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Page url not show other language’ is closed to new replies.