Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUrl treats ip address octets as octal for leading zeros
Qt 6.11 is out! See what's new in the release blog

QUrl treats ip address octets as octal for leading zeros

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 862 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bill Priest
    wrote on last edited by
    #1

    QString urlStr;
    urlStr = "ws://" + "192.168.001.040" + ":" + 4001;
    QUrl url(urlStr);
    qDebug() << "urlStr=" << urlStr;
    qDebug() << "url=" << url.toString();

    output with qt5.10.0
    urlStr="ws://192.168.001.040:4001"
    url="ws://192.168.1.32:4001"

    Clearly QUrl is treating 040 as octal and getting 32. This wasn't what I was expecting.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      I don't see an error here esp. because this is exactly what firefox is doing...
      /edit: an chrome and internet explorer

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      aha_1980A 1 Reply Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        I don't see an error here esp. because this is exactly what firefox is doing...
        /edit: an chrome and internet explorer

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        Interesting - I didn't know this. Seems the octal representation never dies ;)

        @Bill-Priest: As some comments on https://superuser.com/questions/857603/are-ip-addresses-with-and-without-leading-zeroes-the-same/857787 state, the IP stack functions inet_addr and inet_aton lead to this behavior, which is therefore common for many tools.

        So no Qt bug, much more surprising behavior.

        Qt has to stay free or it will die.

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved