2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-11-16 05:09:13 +03:00
|
|
|
|
|
|
|
#ifndef nsURLParsers_h__
|
|
|
|
#define nsURLParsers_h__
|
|
|
|
|
|
|
|
#include "nsIURLParser.h"
|
2012-06-06 07:18:25 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2001-11-16 05:09:13 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// base class for url parsers
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsBaseURLParser : public nsIURLParser {
|
|
|
|
public:
|
|
|
|
NS_DECL_NSIURLPARSER
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-04-30 19:46:04 +03:00
|
|
|
nsBaseURLParser() = default;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2001-11-16 05:09:13 +03:00
|
|
|
protected:
|
|
|
|
// implemented by subclasses
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void ParseAfterScheme(const char *spec, int32_t specLen,
|
|
|
|
uint32_t *authPos, int32_t *authLen,
|
|
|
|
uint32_t *pathPos, int32_t *pathLen) = 0;
|
2001-11-16 05:09:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// an url parser for urls that do not have an authority section
|
|
|
|
//
|
|
|
|
// eg. file:foo/bar.txt
|
|
|
|
// file:/foo/bar.txt (treated equivalently)
|
|
|
|
// file:///foo/bar.txt
|
|
|
|
//
|
|
|
|
// eg. file:////foo/bar.txt (UNC-filepath = \\foo\bar.txt)
|
|
|
|
//
|
|
|
|
// XXX except in this case:
|
2009-05-17 07:21:35 +04:00
|
|
|
// file://foo/bar.txt (the authority "foo" is ignored)
|
2001-11-16 05:09:13 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsNoAuthURLParser final : public nsBaseURLParser {
|
2018-04-30 19:46:04 +03:00
|
|
|
~nsNoAuthURLParser() = default;
|
2014-06-24 20:36:44 +04:00
|
|
|
|
2012-06-06 07:18:25 +04:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-06-06 07:18:25 +04:00
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
#if defined(XP_WIN)
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD ParseFilePath(const char *, int32_t, uint32_t *, int32_t *,
|
|
|
|
uint32_t *, int32_t *, uint32_t *,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
#endif
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD ParseAuthority(const char *auth, int32_t authLen,
|
|
|
|
uint32_t *usernamePos, int32_t *usernameLen,
|
|
|
|
uint32_t *passwordPos, int32_t *passwordLen,
|
|
|
|
uint32_t *hostnamePos, int32_t *hostnameLen,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *port) override;
|
2009-05-17 07:21:35 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void ParseAfterScheme(const char *spec, int32_t specLen, uint32_t *authPos,
|
|
|
|
int32_t *authLen, uint32_t *pathPos,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *pathLen) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// an url parser for urls that must have an authority section
|
|
|
|
//
|
|
|
|
// eg. http:www.foo.com/bar.html
|
|
|
|
// http:/www.foo.com/bar.html
|
|
|
|
// http://www.foo.com/bar.html (treated equivalently)
|
|
|
|
// http:///www.foo.com/bar.html
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsAuthURLParser : public nsBaseURLParser {
|
2014-06-24 20:36:44 +04:00
|
|
|
protected:
|
2018-04-30 19:46:04 +03:00
|
|
|
virtual ~nsAuthURLParser() = default;
|
2014-06-24 20:36:44 +04:00
|
|
|
|
2012-06-06 07:18:25 +04:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-06-06 07:18:25 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD ParseAuthority(const char *auth, int32_t authLen,
|
|
|
|
uint32_t *usernamePos, int32_t *usernameLen,
|
|
|
|
uint32_t *passwordPos, int32_t *passwordLen,
|
|
|
|
uint32_t *hostnamePos, int32_t *hostnameLen,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *port) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD ParseUserInfo(const char *userinfo, int32_t userinfoLen,
|
|
|
|
uint32_t *usernamePos, int32_t *usernameLen,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t *passwordPos,
|
|
|
|
int32_t *passwordLen) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD ParseServerInfo(const char *serverinfo, int32_t serverinfoLen,
|
|
|
|
uint32_t *hostnamePos, int32_t *hostnameLen,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *port) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void ParseAfterScheme(const char *spec, int32_t specLen, uint32_t *authPos,
|
|
|
|
int32_t *authLen, uint32_t *pathPos,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t *pathLen) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// an url parser for urls that may or may not have an authority section
|
|
|
|
//
|
|
|
|
// eg. http:www.foo.com (www.foo.com is authority)
|
|
|
|
// http:www.foo.com/bar.html (www.foo.com is authority)
|
|
|
|
// http:/www.foo.com/bar.html (www.foo.com is part of file path)
|
|
|
|
// http://www.foo.com/bar.html (www.foo.com is authority)
|
|
|
|
// http:///www.foo.com/bar.html (www.foo.com is part of file path)
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsStdURLParser : public nsAuthURLParser {
|
2018-04-30 19:46:04 +03:00
|
|
|
virtual ~nsStdURLParser() = default;
|
2014-06-24 20:36:44 +04:00
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
public:
|
2012-08-22 19:56:38 +04:00
|
|
|
void ParseAfterScheme(const char *spec, int32_t specLen, uint32_t *authPos,
|
|
|
|
int32_t *authLen, uint32_t *pathPos,
|
2017-11-06 06:37:28 +03:00
|
|
|
int32_t *pathLen) override;
|
2001-11-16 05:09:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsURLParsers_h__
|