Esempio n. 1
0
  bool Url::isValid (const QString& url)
  {
    static QString
    VALID_SCHEMAS [] =
    {
        QString("http"),QString("https"),QString("file"),
        QString("svn"),QString("svn+ssh"),QString("svn+http"),QString("svn+https"),QString("svn+file"),
        QString("ksvn"),QString("ksvn+ssh"),QString("ksvn+http"),QString("ksvn+https"),QString("ksvn+file"),
        QString()
    };
    QString urlTest(url);
    unsigned int index = 0;
    while (!VALID_SCHEMAS[index].isEmpty())
    {
      QString&schema = VALID_SCHEMAS[index];
      QString urlComp = urlTest.mid(0, schema.length());

      if (schema == urlComp)
      {
        return true;
      }
      ++index;
    }
    return false;
  }
Esempio n. 2
0
BOOL WebAddress::ShouldCorrectNoSlash(String_256* pstrCorrect)  
{	
	//Check our parameter
	ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectNoSlash - NULL parameter");
	
	//First create a Web Address from our string
	WebAddress urlTest(*pstrCorrect);

	//Now, does the Web Address start with HTTP:, and does it have a net location
	//specified?
	if (urlTest.IsHTTP() && !urlTest.NetLocIsEmpty())
	{
		//Yes.

		//So, does the Web Address have an empty path?
		if (urlTest.PathIsEmpty())
		{
			//Yes. So we should add a slash to it.
			return TRUE;
		}
		else
		{
			//No, there is something in the path.

			//So, does the path end in something other than a slash?
			INT32 iLength=urlTest.Path.Length();

			if (urlTest.Path[iLength-1]!='/')
			{
				//Yes. So we should add a slash only if 
				//the last segment of the path does not contain a full stop.

				//First try and find a slash in the path string, starting
				//from the end
				INT32 iSlashFound=urlTest.Path.ReverseFind('/');

				//Now try and find a full stop in the path string, starting 
				//from the end
				INT32 iFullStopFound=urlTest.Path.ReverseFind('.');

				//Now...

				//If we didn't find a full stop, we should add a slash
				if (iFullStopFound==-1)
					return TRUE;

				//Otherwise, we should only add a slash if the slash
				//was found after the full stop
				if (iSlashFound>iFullStopFound)
					return TRUE;

				//Otherwise, we don't add a slash
			}
		}
	}

	//So, none of our conditions were met.
	//So we don't add a slash
	return FALSE;
}
Esempio n. 3
0
//a_Checks if the URL is "valid"
int ACGI::cgiIsValidURL(const char *pccTest)
{
  //a_NULL string or no string
  if (!pccTest || *pccTest == '\x0') return 0x0;

  //a_Check for metacharacters, strict test
  if (!cgiIsWithoutMetaChar(pccTest, 0x1)) return 0x0;

  AURL urlTest(pccTest);

  return urlTest.urlIsValidURL();
}
Esempio n. 4
0
BOOL WebAddress::IsHTTP(const String_256& strTest)
{
	WebAddress urlTest(strTest);
	return (urlTest.IsHTTP());	
}