PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 9, 2022

[FIXED] Escaping URL Helper in CakePHP

 March 09, 2022     cakephp-3.0, php     No comments   

Issue

I need to send a text email with a link for the user to click. It's a user verification email. The issue I am having is that the URL helper keeps escaping the characters. I feel I have tried the below in every possible combination but to no avail.

echo $this->Url->build([
    "controller" => "Users",
    "action" => "verify", 
    "?" => ['email' => $email, 'hash' => $hash]  
    ],[
    "escape" => false,
    "fullBase" => true
    ]);

This results in http://www.mydomain.co.uk/users/verify?email=chris%40domain.co.uk&hash=b56a4eea3b495db226888f2f89e7678f where the '@' and '&' charachters are beeing escaped.

Another issue with this is that cake can't access the hash variable but it can the email, ie.

echo $this->request->query('hash') //doesn't print anything
echo $this->request->query('email') //prints email with the @ symbol

Solution

Thanks to Greg Schmidt for pointing out the version inconsistency.

FYI; You can only use the escaping for CakePHP version 3.3.5 and above (As of Nov '16).

I used htmlspecialchars_decode($this->Url->build()) to solve the problem



Answered By - ChrisBull
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing