The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Passing special characters through API

Discussion in 'cPanel Developers' started by darkshadow604, Jun 7, 2010.

  1. darkshadow604

    darkshadow604 Active Member

    Joined:
    Feb 4, 2006
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Is there anyway I can pass special characters through a URL for an API call?

    I need to pass for example: *&8/\13%@#^&;'' as the password for one of the arguments for a Fileman::fullbackup API1 call.

    I tried using urlencode() on the password, but got this:
    <error>[an error occurred while processing this directive]</error>

    So I'm thinking... does cPanel convert encoded URL's back to regular strings? [equivalent to urldecode()]? Is there anyway I can get pass this?

    Edit: tried adding htmlentities() so it becomes this -
    $ftppass = urlencode(htmlentities(stripslashes("*&8/\\13%@#^&;\'\'")));
    The call went through, but authentication fails.

    $call = "/xml-api/cpanel?user=${user}&xmlin=<cpanelaction><module>Fileman</module><func>fullbackup</func><apiversion>1</apiversion><args>ftp</args><args>example.com</args><args>abcdef</args><args>${ftppass}</args><args>test@test.com</args><args>21</args><args>/</args></cpanelaction>";

    Edit2: also tried using json-api API1, without the htmlentities, and still to no avail.

    Any help will be appreciated.
     
    #1 darkshadow604, Jun 7, 2010
    Last edited: Jun 8, 2010
  2. darkshadow604

    darkshadow604 Active Member

    Joined:
    Feb 4, 2006
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Can any cPanel staff give me some insights on how to tackle this problem? Or do I have reside to limiting the special characters from being used in passwords?

    Edit: just contacted support, seems that single/double quotes are messing up with the API call.
    - two single quotes infront of the password seems to make the variable undefined.
    - any quotes inside a password closes up the variable up - doesn't treat it as literal.
    Don't know how to tackle this problem.

    Thanks!
     
    #2 darkshadow604, Jun 8, 2010
    Last edited: Jun 15, 2010
  3. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi darkshadow604,

    I've done some preliminary tests and am able to reproduce the issue.
    Code:
    //this is the URL param
    arg-3=%2A%268%2F%5C13%25%40%23%5E%26%3B%27%27
    
    //this is how cPanel has captured it  
    //NOTE: one single quote is escaped, the other is literal...as you've mentioned
    'param3' => '*&8/\\13%@#^&;\''
    
    You say you contacted support? Please private message me the ticket number.

    Hopefully we'll get it address in cPanel. Or if necessary, after we sort it out, we can post a work around on this thread later.

    Regards,
    -David
     
  4. darkshadow604

    darkshadow604 Active Member

    Joined:
    Feb 4, 2006
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Hi David,

    Sorry for the slow reply - didn't get notified of your post. I have PM'ed you the ticket ID.

    Here's the reply a few days ago:
    Though I'm not sure if cPanel has fixed this yet and which branches have been updated with the fix - as I haven't had the time to test it out after the response.

    Regards,
     
  5. lauer

    lauer Member

    Joined:
    Aug 29, 2008
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    This is still a problem in both API1 and API2
    I am using WHM 11.28.64
     
  6. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi lauer,

    Can you please specify a particular API1 or API2 call that is failing for you, and an example parameter that you believe is impeding the success of the call.

    Thanks,
    -DavidN
     
Loading...

Share This Page