LYRemoveBlanks(*href);
convert_to_spaces(*href, FALSE); LYTrimLeading(*href); LYTrimTrailing(*href);
PUBLIC int LYLegitimizeHREF ARGS4(	HTStructured *, 	me,	char **,		href,	BOOL,			force_slash,	BOOL,			strip_dots){    int url_type = 0;    char *pound = NULL;    char *fragment = NULL;    if (!me || !href || *href == NULL || *(*href) == '\0')	return(url_type);    if (!LYTrimStartfile(*href)) {	/*	 *  Collapse spaces in the actual URL, but just	 *  protect against tabs or newlines in the	 *  fragment, if present.  This seeks to cope	 *  with atrocities inflicted on the Web by	 *  authoring tools such as Frontpage. - FM	 */	if ((pound = strchr(*href, '#')) != NULL) {	    StrAllocCopy(fragment, pound);	    *pound = '\0';	    convert_to_spaces(fragment, FALSE);	}	LYRemoveBlanks(*href);	if (fragment != NULL) {	    StrAllocCat(*href, fragment);	    FREE(fragment);	}    }    if (*(*href) == '\0')	return(url_type);    LYUCFullyTranslateString(href, me->tag_charset, me->tag_charset,			     NO, NO, YES, st_URL);    url_type = is_url(*href);    if (!url_type && force_slash &&	(!strcmp(*href, ".") || !strcmp(*href, "..")) &&	 strncmp((me->inBASE ?	       me->base_href : me->node_anchor->address),		 "file:", 5)) {	/*	 *  The Fielding RFC/ID for resolving partial HREFs says	 *  that a slash should be on the end of the preceding	 *  symbolic element for "." and "..", but all tested	 *  browsers only do that for an explicit "./" or "../",	 *  so we'll respect the RFC/ID only if force_slash was	 *  TRUE and it's not a file URL. - FM	 */	StrAllocCat(*href, "/");    }    if ((!url_type && LYStripDotDotURLs && strip_dots && *(*href) == '.') &&	 !strncasecomp((me->inBASE ?		     me->base_href : me->node_anchor->address),		       "http", 4)) {	/*	 *  We will be resolving a partial reference versus an http	 *  or https URL, and it has lead dots, which may be retained	 *  when resolving via HTParse(), but the request would fail	 *  if the first element of the resultant path is two dots,	 *  because no http or https server accepts such paths, and	 *  the current URL draft, likely to become an RFC, says that	 *  it's optional for the UA to strip them as a form of error	 *  recovery.  So we will, recursively, for http/https URLs,	 *  like the "major market browsers" which made this problem	 *  so common on the Web, but we'll also issue a message about	 *  it, such that the bad partial reference might get corrected	 *  by the document provider. - FM	 */	char *temp = NULL, *path = NULL, *cp;	CONST char *str = "";	if (((temp = HTParse(*href,			     (me->inBASE ?			   me->base_href : me->node_anchor->address),			     PARSE_ALL)) != NULL && temp[0] != '\0') &&	    (path = HTParse(temp, "",			    PARSE_PATH+PARSE_PUNCTUATION)) != NULL &&	    !strncmp(path, "/..", 3)) {	    cp = (path + 3);	    if (LYIsHtmlSep(*cp) || *cp == '\0') {		if ((me->inBASE ?	       me->base_href[4] : me->node_anchor->address[4]) == 's') {		    str = "s";		}		if (TRACE) {		    fprintf(tfp,			 "LYLegitimizeHREF: Bad value '%s' for http%s URL.\n",			   *href, str);		    fprintf(tfp,			 "                  Stripping lead dots.\n");		} else if (!me->inBadHREF) {		    HTUserMsg(BAD_PARTIAL_REFERENCE);		    me->inBadHREF = TRUE;		}	    }	    if (*cp == '\0') {		StrAllocCopy(*href, "/");	    } else if (LYIsHtmlSep(*cp)) {		while (!strncmp(cp, "/..", 3)) {		    if (*(cp + 3) == '/') {			cp += 3;			continue;		    } else if (*(cp + 3) == '\0') {			*(cp + 1) = '\0';			*(cp + 2) = '\0';		    }		    break;		}		StrAllocCopy(*href, cp);	    }	}	FREE(temp);	FREE(path);    }    return(url_type);}