Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-5981

Determining the proxy from the systems proxy lists fails on Windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.6.1
    • 4.5.3
    • Network
    • None
    • XP SP3
    • 32ea1aedcf1f588da1ac112bb615088d954b84e1

    Description

      When using a proxy list with more than one proxy (http=http.proxy.de:8000;https=https.proxy.de:8080) the parsing fails when trying to parse the portnumber.

      This Bug ist blocking because it leads to a Qtcreator crash.

      Possible fix: add an additional inner loop over an "const QStringList &entryList = listEntry.split(QLatin1Char(';'), QString::SkipEmptyParts)"

      static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, const QStringList &proxyList)
      {
          // Reference documentation from Microsoft:
          // http://msdn.microsoft.com/en-us/library/aa383912(VS.85).aspx
          //
          // According to the website, the proxy server list is
          // one or more of the space- or semicolon-separated strings in the format:
          //   (
         QList<QNetworkProxy> result;
          foreach (const QString & listEntry, proxyList) {
              
               // THE NEW LOOP
              const QStringList &entryList = listEntry.split(QLatin1Char(';'), QString::SkipEmptyParts);
              foreach (const QString & entry, entryList) {
      
                  int server = 0;
      
                  int pos = entry.indexOf(QLatin1Char('='));
                  if (pos != -1) {
                      QStringRef scheme = entry.leftRef(pos);
                      if (scheme != query.protocolTag())
                          continue;
      
                      server = pos + 1;
                  }
      
                  QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
                  quint16 port = 8080;
      
                  pos = entry.indexOf(QLatin1String("://"), server);
                  if (pos != -1) {
                      QStringRef scheme = entry.midRef(server, pos - server);
                      if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
                          // no-op
                          // defaults are above
                      } else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) {
                          proxyType = QNetworkProxy::Socks5Proxy;
                          port = 1080;
                      } else {
                          // unknown proxy type
                          continue;
                      }
      
                      server = pos + 3;
                  }
      
                  pos = entry.indexOf(QLatin1Char(':'), server);
                  if (pos != -1) {
                      bool ok;
                      uint value = entry.mid(pos + 1).toUInt(&ok);
                      if (!ok || value > 65535)
                          continue;       // invalid port number
      
                      port = value;
                  } else {
                      pos = entry.length();
                  }
      
                  result << QNetworkProxy(proxyType, entry.mid(server, pos - server), port);
              }
          }
      
          return result;
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mgoetz Markus Goetz (Inactive)
            scusi71 Michael Knaup
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes