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.

SOLVED whmapi1 editzonerecord "+" character

Discussion in 'cPanel Developers' started by Haym, Aug 2, 2017.

Tags:
  1. Haym

    Haym Member

    Joined:
    May 12, 2017
    Messages:
    21
    Likes Received:
    5
    Trophy Points:
    3
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Hello,

    Can anyone shed some light on the following behaviour.

    I'm running a command such as the below:

    Code:
    whmapi1 editzonerecord domain='domain.com' line=26 name='domain.com.' class=IN ttl=14400 type=TXT txtdata='v=spf1 +a +mx +ip4:1.1.1.1 include:spf.domain.net ~all'
    The record line updates fine, however the plus signs (+) in the txtdata are replaced with spaces.

    I've tried using unencoded=0 and unencoded=1, which makes no difference. I've tried wrapping the txtdata in quotes as suggested in the API docs but it seems the API actually does this automatically when writing to the zone, as my quotes are escaped and wrapped in another set of quotes. As such, I believe the above is the correct command, but I'm puzzled as to why the + signs are being stripped, which are part if the original record being replaced.

    Thanks
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You will need to encode the entry if you are using those characters. For example, here's an uncoded entry:

    Code:
    v=spf1 +a +mx +ip4:1.1.1.1 include:spf.domain.net ~all
    Encoded, it looks like this:

    Code:
    v%3Dspf1%20%2Ba%20%2Bmx%20%2Bip4%3A1.1.1.1%20include%3Aspf.domain.net%20~all
    I tested this with the following command and it worked properly:

    Code:
    whmapi1 editzonerecord domain=cptest01.tld line=38 name=cptest01.tld. class=IN ttl=14400 type=TXT txtdata="v%3Dspf1%20%2Ba%20%2Bmx%20%2Bip4%3A1.1.1.1%20%2Binclude%3Aspf.domain.net%20~all" unencoded=1
    The updated entry in the zone includes the + symbols:

    Code:
    # grep spf /var/named/cptest01.tld.db
    cptest01.tld.    14400    IN    TXT    "v=spf1 +a +mx +ip4:1.1.1.1 include:spf.domain.net ~all"
    Thank you.
     
  3. Haym

    Haym Member

    Joined:
    May 12, 2017
    Messages:
    21
    Likes Received:
    5
    Trophy Points:
    3
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Perfect, thanks for all of your help today @cPanelMichael!

    For anyone else reading, for clarification, the encoding is URL Encoding.
     
    cPanelMichael likes this.
Loading...

Share This Page