- if ( (!strcmp(furl.scheme, "http") && (furl.port != 80)) ||
- (!strcmp(furl.scheme, "https") && (furl.port != 443))) {
+ if (furl.port && (
+ (!strcmp(furl.scheme, "http") && (furl.port != 80)) ||
+ (!strcmp(furl.scheme, "https") && (furl.port != 443))
+#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
+ || ((!(se = getservbyname(furl.scheme, "tcp"))) || (ntohs(se->s_port) != furl.port))
+#endif
+ )) {