I've noticed strange behaviour with Sugar and textareas. Sugar adds a odd character in front of any £ (GBP) symbol in text areas.
Consider this code:
Code:
<?php
$val = $_REQUEST['test'];
for($i = 0; $i < strlen($val); $i++)
{
var_dump(substr($val, $i, 1));
}
?>
<form method='post' action='/modules/test/test.php'>
<input type='submit'/>
<textarea name='test'></textarea>
</form> If I navigate to /index.php?module=test&action=test and type a GBP symbol into the texarea and submit I get this result:
Code:
string(1) "�"
string(1) "�"
ie two chars, the first being some strange hidden one.
If I now navigate to /modules/test/test.php and do the same thing I get
The action of the form is the php script itself instead of the page handler to avoid Sugar's request cleaning code and eliminate the possibility of the data being manipulated after the post.
So, it seems that somehow the value of the textarea is being changed by Sugar before the form is submitted. (Some javascript thing I suspect) This is causing problems with my custom modules. What's the solution?
Bookmarks