I have an issue with my project where a certain string will cause a client side template injection and xss.
This is the string that causes it: qss%7B%7Bq%3d(2*2.0)%7D%7Dqss.
This will render on the other side as: qss4qss.
But the thing is I have no idea why? I have tried using both escaped & not-escaped to see if it would work. Yet they both seem to be showing the same thing and are computing the 2*2.0 within the string.
Any help would be appreciated and hopefully a solution! :)
Okay, so after doing some digging around for a while and taking a look at other resolutions I finally found one that works well but a bit confusingly.
This is what worked for me:
{!! htmlspecialchars(old('var', $var)) !!}
I was a little confused as of why this worked. Because I thought laravel blades {{ $var }} was meant to use htmlEntities() but htmlEntities() includes ALL characters which are html. So I thought {{$var}} would be more comprehensive than htmlspecialchars() ??
Oh well, fixed my issue and I hope it fixes someone else's too!
So, I want this to be a sanitized input (because it should not perform the calculation) otherwise it's possible for a client side template injection to happen.
So since Laravel provides a "safe" way to echo out strings parsed to it I used: {{ old('email', $email) }} to begin with (which did not work) it was still showing the calculation was performed and 4 was showing still.
Then I tried without escaping such as the snippet shown above and it didn't work either... the calculation was still performed when I don't want it to be!
If you cannot prevent angular interpolating the moustaches, I suggest you write a back end function that disables double braces when it sees them in content.
@tobyreed did you find the answer? I have the same question. Why doesn't {{ $var }} prevent the xss of $var? It is supposed to but in my case it didn't either.