library/src/decoders/HTML/BP-HTMLDecoder.cc
// Sets the blacklist property in the anchor list to true for each matching entry in the blacklist_urls array.
Sets the blacklist property in the anchor list to true for each matching entry in the blacklist_urls array.
Sets the blacklist property in the anchor list to true for each matching entry in the blacklist_urls array .
BP_ERROR_T HTMLApplyAnchorBlacklist(P_BP_HTML_ANCHOR_LIST anchors, char **blacklist_urls, size_t entry_count)
{
	if(!anchors)
		return ERR_FAILURE;
	if(!blacklist_urls)
		return ERR_FAILURE;
	if(!blacklist_urls[0])
		return ERR_FAILURE;
	size_t i = 0;
	for(; anchors != NULL; anchors = anchors->next)
	{
		if(anchors->href)
		{
			for(i = 0; i < entry_count; i++)
			{
				if(blacklist_urls[i][0] != ':')
				{
					if(strstr(anchors->href, blacklist_urls[i] ) == anchors->href)
					{
						anchors->blacklisted = 1;
					}
				}
				else 
				{
					BP_REGEX_MATCH_INFO match_info = {0};
					BP_ERROR_T match_code = BP_MatchRegularExpression(anchors->href,
							bpstrlen(anchors->href),
							(char *)&blacklist_urls[i][1],
							0,
							1,
							(P_BP_REGEX_MATCH_INFO) &match_info
					);
					if(match_code == ERR_SUCCESS)
						anchors->blacklisted = 1;
				}
			}
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T HTMLApplyAnchorBlacklist ( P_BP_HTML_ANCHOR_LIST anchors , char * * blacklist_urls , size_t entry_count ) { if ( ! anchors ) return ERR_FAILURE ; if ( ! blacklist_urls ) return ERR_FAILURE ; if ( ! blacklist_urls [ 0 ] ) return ERR_FAILURE ; size_t i = 0 ; for ( ; anchors != NULL ; anchors = anchors -> next ) { if ( anchors -> href ) { for ( i = 0 ; i < entry_count ; i ++ ) { if ( blacklist_urls [ i ] [ 0 ] != ' ' ) { if ( strstr ( anchors -> href , blacklist_urls [ i ] ) == anchors -> href ) { anchors -> blacklisted = 1 ; } } else { BP_REGEX_MATCH_INFO match_info = { 0 } ; BP_ERROR_T match_code = BP_MatchRegularExpression ( anchors -> href , bpstrlen ( anchors -> href ) , ( char * ) & blacklist_urls [ i ] [ 1 ] , 0 , 1 , ( P_BP_REGEX_MATCH_INFO ) & match_info ) ; if ( match_code == ERR_SUCCESS ) anchors -> blacklisted = 1 ; } } } } return ERR_SUCCESS ; }
Sets the blacklist property in the anchor list to true for each matching entry in the blacklist_urls array.
Sets the blacklist property in the anchor 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 // Ensure anchor pointer is set // walk every entry in the blacklist array, and compare it with the anchor href // if the first character is not a ":", we have a base match type // if the blacklist matches, set the blacklist flag in the form property (from the start) // set the flag to true, this form will not be used when running loops // if it is a ":" we have a regexp match // store match information // match regular expression // check for a successful match // BP_Regmatch_info.matches // TODO: May need to bpfree matches here. // return indicating success