library/src/decoders/HTML/BP-HTMLDecoder.cc
// Sets the blacklist property in the form list to true for each matching entry in the blacklist_urls array.
Sets the blacklist property in the form list to true for each matching entry in the blacklist_urls array.
Sets the blacklist property in the form list to true for each matching entry in the blacklist_urls array .
BP_ERROR_T HTMLApplyFormBlacklist(P_BP_HTML_FORM_LIST forms, char **blacklist_urls, size_t entry_count)
{
	if(!forms)
		return ERR_FAILURE;
	if(!blacklist_urls)
		return ERR_FAILURE;
	if(!blacklist_urls[0])
		return ERR_FAILURE;
	size_t i = 0;
	for(; forms != NULL; forms = forms->next)
	{
		P_BP_HTML_FORM_PROPERTY_LIST firstElem = NULL;
		if(forms->properties)
			firstElem = forms->properties->first;
		if(forms->properties)
		for(
				forms->properties = forms->properties->first;
				forms->properties;
				forms->properties = forms->properties->next
		)
		{
			if(BP_strncasecmp(forms->properties->name, "action", bpstrlen("action"))==0)
			{
				for(i = 0; i < entry_count; i++)
				{
					if(blacklist_urls[i][0] != ':')
					{
						if(
								forms->properties->content == (char *) strstr(forms->properties->content, blacklist_urls[i])
						)
						{
							forms->blacklisted = 1;
						}
					}
					else 
					{
						BP_REGEX_MATCH_INFO match_info = {0};
						BP_ERROR_T match_code = BP_MatchRegularExpression(forms->properties->content,
																		bpstrlen(forms->properties->content),
																		(char *)&blacklist_urls[i][1],
																		0,
																		1,
																		(P_BP_REGEX_MATCH_INFO) &match_info
												);
						if(match_code == ERR_SUCCESS)
							forms->blacklisted = 1;
					}
				}
			}
			forms->properties->first = firstElem;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T HTMLApplyFormBlacklist ( P_BP_HTML_FORM_LIST forms , char * * blacklist_urls , size_t entry_count ) { if ( ! forms ) return ERR_FAILURE ; if ( ! blacklist_urls ) return ERR_FAILURE ; if ( ! blacklist_urls [ 0 ] ) return ERR_FAILURE ; size_t i = 0 ; for ( ; forms != NULL ; forms = forms -> next ) { P_BP_HTML_FORM_PROPERTY_LIST firstElem = NULL ; if ( forms -> properties ) firstElem = forms -> properties -> first ; if ( forms -> properties ) for ( forms -> properties = forms -> properties -> first ; forms -> properties ; forms -> properties = forms -> properties -> next ) { if ( BP_strncasecmp ( forms -> properties -> name , " " , bpstrlen ( " " ) ) == 0 ) { for ( i = 0 ; i < entry_count ; i ++ ) { if ( blacklist_urls [ i ] [ 0 ] != ' ' ) { if ( forms -> properties -> content == ( char * ) strstr ( forms -> properties -> content , blacklist_urls [ i ] ) ) { forms -> blacklisted = 1 ; } } else { BP_REGEX_MATCH_INFO match_info = { 0 } ; BP_ERROR_T match_code = BP_MatchRegularExpression ( forms -> properties -> content , bpstrlen ( forms -> properties -> content ) , ( char * ) & blacklist_urls [ i ] [ 1 ] , 0 , 1 , ( P_BP_REGEX_MATCH_INFO ) & match_info ) ; if ( match_code == ERR_SUCCESS ) forms -> blacklisted = 1 ; } } } forms -> properties -> first = firstElem ; } } return ERR_SUCCESS ; }
Sets the blacklist property in the form list to true for each matching entry in the blacklist_urls array.
Sets the blacklist property in the form list to true for each matching entry in the blacklist_urls array .
// loop index for blacklist iteration loop // walk the form list and run string matches // save the first property if property exists // walk properties if they exist // check to see if the form element has a  property matching the name "target" and run // url checks on its value if so (effectively the main blacklist routine) // walk every entry in the blacklist array, and compare it with the target value // if the blacklist matches, set the blacklist flag in the form property // set the flag to true // if it is a ":" we have a regexp match // store match information // match regular expression // check for a successful match // reset first element after O(n) walk // return indicating success