Results 1 to 4 of 4

Thread: Sugar modifies textareas

  1. #1
    dkelly is offline Sugar Community Member
    Join Date
    May 2005
    Location
    London
    Posts
    77

    Question Sugar modifies textareas

    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

    Code:
    string(1) "£"
    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?

  2. #2
    dkelly is offline Sugar Community Member
    Join Date
    May 2005
    Location
    London
    Posts
    77

    Angry Re: Sugar modifies textareas

    Anyone from the Sugar Team able to comment on this?

  3. #3
    dkelly is offline Sugar Community Member
    Join Date
    May 2005
    Location
    London
    Posts
    77

    Default Re: Sugar modifies textareas

    Some more info about this. If I do a:

    PHP Code:
    echo file_get_contents("php://input"); 
    at the beginning of the target file then I get this result:

    PHP Code:
    test=%C2%A3 
    which indicates that the raw post data received by PHP does, in fact, have a %C2 (Â) character inserted before the £ sign. Since php://input is read only this means that the POST data must be being altered by Sugar before the actual POST.

    What text validation / manipulation javascript is done on forms?

  4. #4
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Sugar modifies textareas

    Very interesting, and a bit disturbing...Unfortunately, I'm not very good at javascript. But I would like this sorted out as well.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sugar Integration Best Practices
    By alec.maki in forum Developer Help
    Replies: 6
    Last Post: 2007-12-10, 11:27 AM
  2. Sugar Upgradability -> Needs community input
    By lvangool in forum Feature Requests
    Replies: 7
    Last Post: 2007-03-09, 07:39 PM
  3. Sugar Open Source 3.5.1e Available for Download
    By clint in forum Announcements
    Replies: 0
    Last Post: 2005-12-10, 06:29 AM
  4. Who is working on which translations?
    By clint in forum Translators
    Replies: 5
    Last Post: 2005-08-26, 02:44 PM
  5. Sugar Suite 3.5 Beta Now Available
    By clint in forum Announcements
    Replies: 0
    Last Post: 2005-08-01, 02:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •