Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-05

URIParser

19 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I have tried to use the URIParser on a structure like so:

;name=test?header=something

That's the most complicated SIP URI according to the RFC (3261).

But the record was able to just return to me the protocol (sip) and nothing else.
Does the unit implement it according to the URI RFC ? if so, what version of that (2396 or 3986) ?

Thanks,

Ido

LINESIP - Opening the source for communication
http://www.linesip.com
http://www.linesip.co.il

Reply by email

ik
to ik

I've created a more simple example:

program uri_test;
uses URIParser;
var
  URI : TURI;
begin
  URI := ParseURI('');
  writeln('URI:');
  writeln(#9'Protocol: ', URI.Protocol);
  writeln(#9'Username: ', URI.Username);
  writeln(#9'Password: ', URI.Password);
  writeln(#9'Host: ', URI.Host);
  writeln(#9'Port: ', URI.Port);
  writeln(#9'Path: ', URI.Path);
  writeln(#9'Document: ', URI.Document);
  writeln(#9'Params: ', URI.Params);
  writeln(#9'Bookmark: ', URI.Bookmark);
  writeln(#9'HasAuthority: ', URI.HasAuthority);
end.

The output is:
URI:
Protocol: sip
Username:
Password:
Host:
Port: 0
Path:
Document:
Params:
Bookmark:
HasAuthority: FALSE

Ido

ik wrote 25 lines
Hello, I have tried to use the URIParser on a structure like so: ;name=test?header=something That's the most complicated SIP URI according to the RFC (3261). But the record was able to just return to me the protocol (sip) and nothing else. Does the unit implement it according to the URI RFC ? if so, what version of that (2396 or 3986) ? Thanks, Ido LINESIP - Opening the source for communication http://www.linesip.com http://www.linesip.co.il

Reply by email

Unknown author
to ik
ik wrote 9 lines
I've created a more simple example: program uri_test; uses URIParser; var URI : TURI; begin

You don't specify the protocol.

a URI starts always with "protocol://"

so

The URIParser unit expects the protocol to be in place.

Michael.

Reply by email

ik
to Unknown author
Show quoted text 21 lines
On Wed, 18 May 2011, ik wrote: I've created a more simple example: > > program uri_test; > uses URIParser; > > var > URI : TURI; > > begin > You don't specify the protocol. a URI starts always with "protocol://" so

The problem is that the SIP URI (
http://tools.ietf.org/html/rfc3261#section-19.1 and http://tools.ietf.org/html/rfc3261#section-19.1.1) are more like the mailto: URI then the HTTP URI.

RFC 3986 <http://tools.ietf.org/html/rfc3986> does talk about such structure of URI as well.

Show quoted text 5 lines
The URIParser unit expects the protocol to be in place. Michael.

Thanks,

Ido

_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Ludo Brands
to Unknown author: You don't specify the protocol. a URI starts always with "protocol://" so The URIParser…
> a URI starts always with "protocol://"

RFC 2396 (http://tools.ietf.org/html/rfc2396 ) specifies that an URI has to start with the protocol and a colon. The // depends on the protocol scheme. Valid URI's are for example or
news:comp.infosystems.www.servers.unix. The SIP URI is ;uri-parameters?headers and
;uri-parameters?headers for secure sip
(http://tools.ietf.org/html/rfc3261#page-148).

Ludo

Earlier message 32 lines
-----Message d'origine----- De : De la part de Envoyé : mercredi 18 mai 2011 14:50 À : FPC-Pascal users discussions Objet : Re: [fpc-pascal] Re: URIParser On Wed, 18 May 2011, ik wrote: > I've created a more simple example: > > program uri_test; > uses URIParser; > > var > URI : TURI; > > begin You don't specify the protocol. a URI starts always with "protocol://" so The URIParser unit expects the protocol to be in place. Michael.

Reply by email

Ludo Brands
to Unknown author: Hmmm. How can code distinguish between and ? Michael.
Show quoted text 6 lines
How can code distinguish between and

Protocol is missing from the last one = not an URI. A protocol is asumed. Browsers assume http:, mailers mailto:, telnet assumes telnet:, etc

Ludo

Earlier message 57 lines
-----Message d'origine----- De : De la part de Envoyé : mercredi 18 mai 2011 15:12 À : FPC-Pascal users discussions Objet : Re: [fpc-pascal] Re: URIParser On Wed, 18 May 2011, ik wrote: > On Wed, May 18, 2011 at 15:50, wrote: > >> >> >> On Wed, 18 May 2011, ik wrote: >> >> I've created a more simple example: >>> >>> program uri_test; >>> uses URIParser; >>> >>> var >>> URI : TURI; >>> >>> begin >>> >> >> You don't specify the protocol. >> >> a URI starts always with "protocol://" >> >> so >> > > The problem is that the SIP URI ( > http://tools.ietf.org/html/rfc3261#section-19.1 and > http://tools.ietf.org/html/rfc3261#section-19.1.1) > are more like the mailto: URI then the HTTP URI. > > RFC 3986 <http://tools.ietf.org/html/rfc3986> does talk about such > structure of URI as well. Hmmm. How can code distinguish between and ? Michael.

Reply by email

Unknown author
to ik: The problem is that the SIP URI ( http://tools.ietf.org/html/rfc3261#section-19.1 and…
ik wrote 31 lines
On Wed, May 18, 2011 at 15:50, wrote: > > > On Wed, 18 May 2011, ik wrote: > > I've created a more simple example: >> >> program uri_test; >> uses URIParser; >> >> var >> URI : TURI; >> >> begin >> > > You don't specify the protocol. > > a URI starts always with "protocol://" > > so > The problem is that the SIP URI ( http://tools.ietf.org/html/rfc3261#section-19.1 and http://tools.ietf.org/html/rfc3261#section-19.1.1) are more like the mailto: URI then the HTTP URI. RFC 3986 <http://tools.ietf.org/html/rfc3986> does talk about such structure of URI as well.

Hmmm.

How can code distinguish between

and

?

Michael.

Reply by email

ik
to Marco van de Voort: In our previous episode, said: The second is not an uri ?
Marco van de Voort wrote 19 lines
In our previous episode, said: > > > > RFC 3986 <http://tools.ietf.org/html/rfc3986> does talk about such structure > > of URI as well. > > Hmmm. > > How can code distinguish between > > > > and > > > ? The second is not an uri ?

It is, but as far as I understand, you can not have a password without a user according to RFC3986 <http://tools.ietf.org/html/rfc3986#section-3.2>

Ido

_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

ik
to Unknown author: So, how to distinguish between the two ? Is "sip" the protocol or the user name for a…
Show quoted text 43 lines
On Wed, 18 May 2011, ik wrote: On Wed, May 18, 2011 at 16:08, Marco van de Voort > wrote: > > In our previous episode, said: >> >>> >>>> RFC 3986 <http://tools.ietf.org/html/rfc3986> does talk about such >>>> >>> structure >> >>> of URI as well. >>>> >>> >>> Hmmm. >>> >>> How can code distinguish between >>> >>> >>> >>> and >>> >>> >>> ? >>> >> >> The second is not an uri ? >> >> > It is, but as far as I understand, you can not have a password without a > user according to RFC3986 <http://tools.ietf.org/html/rfc3986#section-3.2 > > > So, how to distinguish between the two ? Is "sip" the protocol or the user name for a HTTP address ?

sip is the protocol, mysecrect is the user name

according to the RFC is the proper way to have
1. Protocol
2. Empty user name
3. Password
4. Domain

Michael.

Ido

_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Unknown author
to ik: It is, but as far as I understand, you can not have a password without a user according…
ik wrote 24 lines
On Wed, May 18, 2011 at 16:08, Marco van de Voort wrote: > In our previous episode, said: >>> >>> RFC 3986 <http://tools.ietf.org/html/rfc3986> does talk about such > structure >>> of URI as well. >> >> Hmmm. >> >> How can code distinguish between >> >> >> >> and >> >> >> ? > > The second is not an uri ? > It is, but as far as I understand, you can not have a password without a user according to RFC3986 <http://tools.ietf.org/html/rfc3986#section-3.2>

So, how to distinguish between the two ?

Is "sip" the protocol or the user name for a HTTP address ?

Michael.

Reply by email

Unknown author
to ik: sip is the protocol, mysecrect is the user name according to the RFC is the proper way to…
ik wrote 18 lines
On Wed, May 18, 2011 at 16:49, wrote: > So, how to distinguish between the two ? > > > > Is "sip" the protocol or the user name for a HTTP address ? > sip is the protocol, mysecrect is the user name according to the RFC is the proper way to have 1. Protocol 2. Empty user name 3. Password 4. Domain

I will check the implementation.

As far as I know, it was never meant to be RFC compliant, but we can change that of course.

Michael.

Reply by email

Ludo Brands
to Unknown author

Problem is that the RFC definition for the URI doesn't specify the individual protocol scheme. So every protocol can specify it's own stuff.

Take the general sip URI:
;uri-parameters?headers. User can be a telephone
number with folowing definition: global-phone-number = "+" base-phone-number [isdn-subaddress]
[post-dial] *(area-specifier /
service-provider / future-extension)
Or
local-phone-number = 1*(phonedigit / dtmf-digit / pause-character) [isdn-subaddress]
[post-dial] area-specifier
*(area-specifier / service-provider /
future-extension)
This definitely will require custom processing.
Also both uri-parameters and headers are name=value pairs. The first are separated by ";" and the second by "&"...

I'm afraid a universal URI decoder isn't possible.

Ludo

Earlier message 38 lines
-----Message d'origine----- De : De la part de Envoyé : mercredi 18 mai 2011 16:14 À : FPC-Pascal users discussions Objet : Re: [fpc-pascal] Re: URIParser On Wed, 18 May 2011, ik wrote: > On Wed, May 18, 2011 at 16:49, wrote: >> So, how to distinguish between the two ? >> >> >> >> Is "sip" the protocol or the user name for a HTTP address ? >> > > sip is the protocol, mysecrect is the user name > > > > according to the RFC is the proper way to have > 1. Protocol > 2. Empty user name > 3. Password > 4. Domain I will check the implementation. As far as I know, it was never meant to be RFC compliant, but we can change that of course. Michael.

Reply by email

Unknown author
to Ludo Brands
Ludo Brands wrote 20 lines
Problem is that the RFC definition for the URI doesn't specify the individual protocol scheme. So every protocol can specify it's own stuff. Take the general sip URI: ;uri-parameters?headers. User can be a telephone number with folowing definition: global-phone-number = "+" base-phone-number [isdn-subaddress] [post-dial] *(area-specifier / service-provider / future-extension) Or local-phone-number = 1*(phonedigit / dtmf-digit / pause-character) [isdn-subaddress] [post-dial] area-specifier *(area-specifier / service-provider / future-extension) This definitely will require custom processing. Also both uri-parameters and headers are name=value pairs. The first are separated by ";" and the second by "&"... I'm afraid a universal URI decoder isn't possible.

Great.
In that case I just declare that URIParser will only work for ftp and http protocols :-)

Michael.

Reply by email

ik
to Unknown author
Show quoted text 30 lines
On Wed, 18 May 2011, Ludo Brands wrote: Problem is that the RFC definition for the URI doesn't specify the > individual protocol scheme. So every protocol can specify it's own stuff. > > Take the general sip URI: > ;uri-parameters?headers. User can be a > telephone > number with folowing definition: global-phone-number = "+" > base-phone-number [isdn-subaddress] > [post-dial] *(area-specifier / > service-provider / future-extension) > Or > local-phone-number = 1*(phonedigit / dtmf-digit / > pause-character) [isdn-subaddress] > [post-dial] area-specifier > *(area-specifier / service-provider / > future-extension) > This definitely will require custom processing. > Also both uri-parameters and headers are name=value pairs. The first are > separated by ";" and the second by "&"... > > I'm afraid a universal URI decoder isn't possible. > Great. In that case I just declare that URIParser will only work for ftp and http protocols :-)

I think it is possible. You can also add another field to the record of "Extra data" and allow others to parse it.
the headers are like the HTTP URI (even the encoding of it is the same), and the params are like the HTTP Post more or less but divided by a semicolon. But I can work with parsing it myself imho, because that part is either starting with question mark or by semicolon.

Michael.

Ido

_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Ludo Brands
to ik

The differences I mentioned are just the tip of the iceberg. Another example: the RFC definition for URI permits for every scheme to define their own character escape sequence for special and non ascii-characters. Guess what: sip allows reserved characters in the user field : ;user=phone. Another one?
sip:alice; is allowed and means
user="alice;day=tuesday". (both from
http://tools.ietf.org/html/rfc3261#section-19.1.23) An "extra" field is not going to be enough to get around these differences I'm afraid.

Ludo

Earlier message 62 lines
-----Message d'origine----- De : De la part de ik Envoyé : mercredi 18 mai 2011 17:03 À : FPC-Pascal users discussions Objet : Re: RE : [fpc-pascal] Re: URIParser On Wed, May 18, 2011 at 17:56, wrote: On Wed, 18 May 2011, Ludo Brands wrote: Problem is that the RFC definition for the URI doesn't specify the individual protocol scheme. So every protocol can specify it's own stuff. Take the general sip URI: ;uri-parameters?headers. User can be a telephone number with folowing definition: global-phone-number = "+" base-phone-number [isdn-subaddress] [post-dial] *(area-specifier / service-provider / future-extension) Or local-phone-number = 1*(phonedigit / dtmf-digit / pause-character) [isdn-subaddress] [post-dial] area-specifier *(area-specifier / service-provider / future-extension) This definitely will require custom processing. Also both uri-parameters and headers are name=value pairs. The first are separated by ";" and the second by "&"... I'm afraid a universal URI decoder isn't possible. Great. In that case I just declare that URIParser will only work for ftp and http protocols :-) I think it is possible. You can also add another field to the record of "Extra data" and allow others to parse it. the headers are like the HTTP URI (even the encoding of it is the same), and the params are like the HTTP Post more or less but divided by a semicolon. But I can work with parsing it myself imho, because that part is either starting with question mark or by semicolon. Michael. Ido

Reply by email

Ben
to Unknown author: Great. In that case I just declare that URIParser will only work for ftp and http…
Great. In that case I just declare that URIParser will only work for ftp and http protocols :-)

What about file protocols like the 'text/uri-list' mime type? Such as what X11's XDND uses when you drag and drop from a local application window to a remote application window? In such cases one should supply the username and password with the origin host. Or like Qt4 DND and newer Windows DND applications uses.

eg: text/url-list mime type

I presume (though that always tends to be a bad thing) that because text/uri-list [as in my example above] should be ok with the FPC URIParser because it has the protocol 'file://' in the front - so authority info shouldn't be a problem? After all, file:// is pretty much identical to ftp:// URI syntax.

Ben.

Reply by email

ik
to Ben
Ben wrote 24 lines
On 18/05/2011 16:56, wrote: > > Great. > In that case I just declare that URIParser will only work for ftp and http > protocols :-) What about file protocols like the 'text/uri-list' mime type? Such as what X11's XDND uses when you drag and drop from a local application window to a remote application window? In such cases one should supply the username and password with the origin host. Or like Qt4 DND and newer Windows DND applications uses. eg: text/url-list mime type I presume (though that always tends to be a bad thing) that because text/uri-list [as in my example above] should be ok with the FPC URIParser because it has the protocol 'file://' in the front - so authority info shouldn't be a problem? After all, file:// is pretty much identical to ftp:// URI syntax.

After a lot of careful investigation and mostly reading, I think that you can not really create a general purpose URI parser. It seems though that the FPC implementation is a *URL* and not a full URI parser, and I think it's better to document about it further. For example there are no URN support at all and it works only for specific type of URL that are mostly common, like the example you placed here.

Show quoted text 7 lines
-- Ben.

Ido

Show quoted text 5 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

LINESIP - Opening the source for communication
http://www.linesip.com
http://www.linesip.co.il

Reply by email