Subject: [DNSOP] IE's domain highlighting algorithm

From: Gervase Markham <[email-masked]>
Date: Mon, 25 Aug 2008 17:39:48 +0100

IE 8 has a mechanism for highlighting the "owning domain" of the current
website in the address bar.[0] As they are not using the Public Suffix
List, I asked if they would explain their algorithm for deciding what to
highlight.

A Microsoft engineer was kind enough to explain the algorithm to me, and
I have reimplemented it in Perl for my own understanding. I thought it
might also be of interest to DNSOP. Please find it attached. Note that
this is the algorithm for determining the "domain" property of the IURI
object; its (close) relationship to what is highlighted is explained in
comments in the script.

DNSOP might find it instructive to compare their approach with that of
KDE[1] and of Mozilla.

Gerv

[0]
http://blogs.msdn.com/ie/archive/2008/03/11/address-bar-improvements-in-internet-explorer-8-beta-1.aspx
[1] http://www.ietf.org/mail-archive/web/dnsop/current/msg06185.html
IE 8 has a mechanism for highlighting the "owning domain" of the current
website in the address bar.[0] As they are not using the Public Suffix
List, I asked if they would explain their algorithm for deciding what to
highlight.

A Microsoft engineer was kind enough to explain the algorithm to me, and
I have reimplemented it in Perl for my own understanding. I thought it
might also be of interest to DNSOP. Please find it attached. Note that
this is the algorithm for determining the "domain" property of the IURI
object; its (close) relationship to what is highlighted is explained in
comments in the script.

DNSOP might find it instructive to compare their approach with that of
KDE[1] and of Mozilla.

Gerv

[0]
http://blogs.msdn.com/ie/archive/2008/03/11/address-bar-improvements-in-internet-explorer-8-beta-1.aspx
[1] http://www.ietf.org/mail-archive/web/dnsop/current/msg06185.html
IyEvdXNyL2Jpbi9wZXJsIC13CiMgSW1wbGVtZW50YXRpb24gb2YgdGhlIElFIGFsZ29yaXRobSBmb3IgZGV0ZXJtaW5pbmcgdGhlIElVUkkgJ2RvbWFpbicgCiMgcHJvcGVydHkgZnJvbSBhIEZRRE4uIFRoaXMgcHJvcGVydHkgaXMgaW1wb3J0YW50IGluIGRldGVybWluaW5nIHRoZSAKIyBiZWhhdmlvdXIgb2YgSUUgOCdzIGFkZHJlc3MgYmFyIGhpZ2hsaWdodGluZy4KIyAKIyBXcml0dGV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IGdldERvbWFpbigiYS5wbCIpIHJldHVybnMgImEucGwiCiAgIyBnZXREb21haW4oImEudWsiKSByZXR1cm5zICIiICAKICAjIEdSTSBOT1RFOiBubyBjaGVjayBvbiBMMiBiZWNhdXNlIGl0J3MgY2F1Z2h0IGJ5IGNvZGUgYWJvdmUKICBpZiAoJGxhYmVsc1stMV0gPX4gL14oZ3J8cGwpJC8pIHsKICAgIHByaW50IFNUREVSUiAiUnVsZSA3OiAuZ3IgYW5kIC5wbCBhcmUgc3BlY2lhbC5cbiI7CiAgICByZXR1cm4gMjsKICB9CgogICMgOD4gSWYgTGVuKEwyKSA8IDMgZ2V0RG9tYWluIHJldHVybnMgTDMuTDIuTDE7IGV4aXQuCiAgIyBnZXREb21haW4oImFhLmJiLmNjIikgcmV0dXJucyAiYWEuYmIuY2MiCiAgaWYgKGxlbmd0aCgkbGFiZWxzWy0yXSkgPCAzKSB7CiAgICBwcmludCBTVERFUlIgIlJ1bGUgODogbGVuZ3RoKEwyKSA8IDMuXG4iOwogICAgcmV0dXJuIDM7CiAgfQoKICAjIDk+IE90aGVyd2lzZSwgZ2V0RG9tYWluIHJldHVybnMgTDIuTDEKICAjIGdldERvbWFpbigiYWEuYmJiLmNjIikgcmV0dXJucyAiYmJiLmNjIgogIHByaW50IFNUREVSUiAiUnVsZSA5OiBkZWZhdWx0LlxuIjsKICByZXR1cm4gMjsKfQo=

_______________________________________________
DNSOP mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/dnsop

---

From: David Conrad <[email-masked]>
Date: Mon, 25 Aug 2008 11:23:34 -0700

Hi,

I admit I'm a bit confused.

>  # 4> Check L1 == "tv".  If so, getDomain returns L2.L1; exit.
>  # "tv" is a special-case "completely flat" ccTLD for historical  
> reasons.
...
>  # 6> Check if L2 in gTLD list "com,edu,net,org,gov,mil,int".  If so,
>  # getDomain returns L3.L2.L1; exit.
>  # gTLDs, when they appear immediately left of a ccTLD (modulo  
> exception in
>  # step 4), are considered a part of the TLD.
>  if ($labels[-2] =~ /^(com|edu|net|org|gov|mil|int)$/) {
...
>  # 7> If L1 is in the list "GR,PL" AND L2 is NOT in the gTLD list,  
> getDomain
>  # returns L2.L1; exit.
>  # GR and PL are considered "flat" ccTLDs EXCEPT when a gTLD appears  
> in L2.
>  # getDomain("a.pl") returns "a.pl"
>  # getDomain("a.uk") returns ""
>  # GRM NOTE: no check on L2 because it's caught by code above
>  if ($labels[-1] =~ /^(gr|pl)$/) {
...
>  # 8> If Len(L2) < 3 getDomain returns L3.L2.L1; exit.
>  # getDomain("aa.bb.cc") returns "aa.bb.cc"
>  if (length($labels[-2]) < 3) {
>    print STDERR "Rule 8: length(L2) < 3.\n";
>    return 3;
>  }
...
>   # 9> Otherwise, getDomain returns L2.L1
>  # getDomain("aa.bbb.cc") returns "bbb.cc"
>  print STDERR "Rule 9: default.\n";
>  return 2;

What is this code trying to do?

Thanks,
-drc

---

From: David Conrad <[email-masked]>
Date: Mon, 25 Aug 2008 11:23:34 -0700

Hi,

...
...
...
...

Thanks,
-drc

---

From: Gervase Markham <[email-masked]>
Date: Mon, 25 Aug 2008 22:27:36 +0100

> What is this code trying to do?

The code you quoted returns the number of domain labels, counting from
the right hand end, which are used to make up the "domain" property
(e.g. 2). The code works this way because those are the terms in which
the algorithm was described to me.

Have you tried running it on some example FQDNs, like www.google.com or
foo.bar.se? That should give an idea of what it does overall.

Gerv

---

From: Gervase Markham <[email-masked]>
Date: Mon, 25 Aug 2008 22:27:36 +0100

Gerv

---

From: David Conrad <[email-masked]>
Date: Mon, 25 Aug 2008 17:45:52 -0700

Gervase,

> the algorithm was described to me.

I'm having a bit of trouble understanding the logic behind the  
algorithm.  For example, why are TV, PL, and GR treated as special  
cases? What does it mean when it says '"tv" is a special-case  
"completely flat" ccTLD for historical reasons." when TV is _far_ from  
the only ccTLD that is "completely flat"? What is the expected  
behavior when faced with a TLD like (say) JP that has both a flat name  
space and a structured name space (that is, names like foo.jp and  
foo.co.jp both exist)?  Rule 5 implies that all IDN ccTLDs will be  
considered gTLDs -- is that intended?  Why are only 7 of the original  
TLDs checked in rule 6?

> foo.bar.se? That should give an idea of what it does overall.

Yes.  Hence my confusion.

Let me rephrase my question:

What are the requirements this code is trying to meet?

Regards,
-drc

---

From: David Conrad <[email-masked]>
Date: Mon, 25 Aug 2008 17:45:52 -0700

Gervase,

Yes.  Hence my confusion.

Regards,
-drc