CakePHP 3.4.2 autoLinkUrls failing on %

Text->autoLinkUrls only links up to the first % sign.

Is this working as intended or a bug.

Post your code that is causing the issue so we can assist.

echo $this->Text->autoLinkUrls($practitioner->events);

$practitioner->events = "Yoga in Healthcare: The History, the Science, the Practice: https://www.uvm.edu/medicine/pih/Yoga%20in%20Healthcare%2010_6_16.mp4"

The result = Yoga in Healthcare: The History, the Science, the Practice: <a href="https://www.uvm.edu/medicine/pih/Yoga">https://www.uvm.edu/medicine/pih/Yoga</a>%20in%20Healthcare%2010_6_16.mp4

I’d prefer not having %20 in my urls, but that isn’t my call, they are remote links controlled by someone else. :frowning:

My workaround isn’t ideal, but works: echo str_replace('zzzzz', '%20', $this->Text->autoLinkUrls(str_replace('%20', 'zzzzz', $practitioner->events)));

%20 is a placeholder for a space in the URL.

Looking at the actual code for the autoLinkUrls method, your workaround is all that will work, as there is no flag that you can set that does not prevend this behaviour.

1 Like