mysql - Laravel truncating strings with special characters -
i have been working on cms months now, have faced various challenges laravel truncating special characters. had change editor in cms bootstrap wysiwyg ckeditor things got quite better there advance escaping options come it. example able prevent '"' becoming '" causing entire string (paragraph) truncate ever finds such encoding.
however cms user has reason input wide range of characters can safely encoded , kept in database in cases special chars unavoidable. example picking embed website (very allowed) may contain of these characters;
/ = %2f : = %3a # = %23 % = %25 ? = %3f when pastes link contains characters or tries hyperlink words contain characters ones above(excluding %2f) string truncated. after doing inspection @ various levels noticed string gets back-end function it's truncated before being saved. don't know if laravel (the parser) or mysql (the database use) truncates these strings. here particular case;
when facebook embed :
<iframe src="https://www.facebook.com/plugins/comment_embed.php?href=https%3a%2f%2fwww.facebook.com%2ftonyelumelu%2fposts%2f10154627801036949%3fcomment_id%3d10154629134011949&include_parent=false" width="560" height="201" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowtransparency="true"> </iframe> is pasted in editor found in database
<iframe src="https://www.facebook.com/plugins/comment_embed.php?href=https://www.facebook.com/tonyelumelu/posts/10154627801036949?comment_id=10154629134011949 careful observation show '%2f' replace in string '/' string truncated @ '%3f' supposed replaced '?' or @ least left unchanged.
i know security measures have tweaked front editor alot , think end sanitation should left me (if want) way want. need first know how stop such annoying behavior before getting advice on best practice. strings database way comes without changes. in advance.
trying repeat bug
i create test route route::any('/test', 'indexcontroller@test')->name('test');
then - test action:
public function test(request $request) { if($request->ismethod('post')) { $er = \app\entity::create([ 'log' => $request->code, ]); exit('done'); } echo "<form method=post>" . csrf_field() . "<textarea name=code></textarea><input type=submit></form>"; } results
when submit code, can see unaltered in network tab of browser
then go database , see code unaltered well.
what mean
unfortunally, unable repeat bug presented here. means not laravel transforms code unexpectedly. try check network tab , dd() request vars check them. suppose bug somewhere before sending data via network.


Comments
Post a Comment