static bool verifyProtocolHandlerScheme(const String& scheme, const String& method, ExceptionState& exceptionState)
{
    if (scheme.startsWith("web+")) {
        // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix).
        if (scheme.length() >= 5 && isValidProtocol(scheme))
            return true;
        if (!isValidProtocol(scheme))
            exceptionState.throwSecurityError("The scheme '" + scheme + "' is not a valid protocol.");
        else
            exceptionState.throwSecurityError("The scheme '" + scheme + "' is less than five characters long.");
        return false;
    }

    if (isProtocolWhitelisted(scheme))
        return true;
    exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belong to the protocol whitelist. Please prefix non-whitelisted schemes with the string 'web+'.");
    return false;
}
static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionCode& ec)
{
    if (isProtocolWhitelisted(scheme))
        return true;

    if (scheme.startsWith("web+")) {
        // The specification requires that the length of scheme is at least five characters (including 'web+' prefix).
        if (scheme.length() >= 5 && isValidProtocol(scheme))
            return true;
    }

    ec = SECURITY_ERR;
    return false;
}
static bool verifyProtocolHandlerScheme(const String& scheme)
{
    if (isProtocolWhitelisted(scheme))
        return true;

    // FIXME: Should this be case sensitive, or should it be ASCII case-insensitive?
    if (scheme.startsWith("web+")) {
        // The specification requires that the length of scheme is at least five characters (including 'web+' prefix).
        if (scheme.length() >= 5 && isValidProtocol(scheme))
            return true;
    }

    return false;
}
Exemplo n.º 4
0
static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionCode& ec)
{
    if (scheme.startsWith("web+")) {
        if (isValidProtocol(scheme))
            return true;
        ec = SECURITY_ERR;
        return false;
    }

    if (isProtocolWhitelisted(scheme))
        return true;
    ec = SECURITY_ERR;
    return false;
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
  QCoreApplication application(argc, argv);
  application.addLibraryPath(".");

  QTextStream out(stdout, QIODevice::WriteOnly);

  if (argc > 1)
  {
    QString databaseURL;
    QString username;
    QString passwd;
    QString arguments;
    QString dbServer = QString::null;


    for (int counter = 1; counter < argc; counter++)
    {
      QString arguments(argv[counter]);

      if (arguments.startsWith("-databaseURL=", Qt::CaseInsensitive))
        databaseURL = arguments.right(arguments.length() - 13);
      else if (arguments.startsWith("-username="******"-passwd=", Qt::CaseInsensitive))
        passwd = arguments.right(arguments.length() - 8);
      else if (arguments.startsWith("-dbengine=", Qt::CaseInsensitive))
        dbServer = arguments.right(arguments.length() - 10);
    }


    if (  (databaseURL != "") &&
          (username != "")    &&
          (passwd != "")          ) 
    {

      QSqlDatabase db;
      QString protocol = QString::null;
      QString server   = QString::null;
      QString database = QString::null;
      QString port     = QString::null;

      // Note: parseDatabaseURL returns a default port of 5432 (Default Postgresql port)
      //       is this a bug or a feature ?
      parseDatabaseURL(databaseURL, protocol, server, database, port);

      // treat odbc connections as a special case
      if ( protocol == "odbc")
      {
        if ( dbServer == QString::null )
        {
          out << " database URL = " << databaseURL << endl;
          out << "Protocol=" << protocol << ", Host=" << server << ", Database=" << database << ", port=" << port << endl;
          out << "\"--dbengine=\" parameter required when url protocol is odbc" << endl;
          exit(EXIT_ERROR_MISSING_DB_ENGINE);
        }
        if (! isValidProtocol(dbServer, false) )
        {
          out << "Unrecognised database server: [--dbengine=" << dbServer << "]" << endl;
          out << "Protocol=" << protocol << ", Host=" << server << ", Database=" << database << ", port=" << port << endl;
          exit(EXIT_ERROR_DB_ENGINE);
        }
      }

      // Open the Database Driver
      db = databaseFromURL( databaseURL );
      if (!db.isValid())
      {
        out << " database URL = " << databaseURL << endl;
        out << "Protocol=" << protocol << ", Host=" << server << ", Database=" << database << ", port=" << port << endl;
        out << "Could not load the specified database driver." << endl;
        exit(EXIT_ERROR_DB_DRIVER);
      }

      //  Try to connect to the Database
      db.setUserName(username);
      db.setPassword(passwd);
      if (!db.open())
      {
        out << "Protocol=" << protocol << ", Host=" << db.hostName() << 
              ", Database=" << db.databaseName() << ", port=" << db.port() << endl;
        out << "Could not log into database.  System Error: "
            << db.lastError().text() << endl;
        exit(EXIT_ERROR_DB_LOGIN);
      }

      if ( ! buildTable(db, out, dbServer) ) 
        exit(EXIT_ERROR_DB_TABLE_BUILD);
    }
    else if (databaseURL == "")
    {
      out << "You must specify a Database URL by using the -databaseURL= parameter." << endl;
      exit(EXIT_ERROR_MISSING_URL);
    }
    else if (username == "")
    {
      out << "You must specify a Database Username by using the -username= parameter." << endl;
      exit(EXIT_ERROR_MISSING_USERNAME);
    }
    else if (passwd == "")
    {
      out << "You must specify a Database Password by using the -passwd= parameter." << endl;
      exit(EXIT_ERROR_MISSING_PASSWORD);
    }
  }
  else
  {
    out << "Usage: bldtbls -databaseURL='$' -username='******' -passwd='$' [-dbengine='$']" << endl;
    exit(EXIT_ERROR_BAD_ARGS);
  }

  return EXIT_SUCCESS;
}