Skip to content

Commit

Permalink
Proper distinction between failure reasons
Browse files Browse the repository at this point in the history
This PR fixes a minor flaw in `ozh_yourls_antispam_check_add` in the antispam plugin:

Said function does not distinguish between the two failure reasons a) blacklisted and b) malformed URL.
  • Loading branch information
BstName committed Mar 31, 2016
1 parent 3bca060 commit bcb9b9f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugin.php
Expand Up @@ -19,14 +19,23 @@ function ozh_yourls_antispam_check_add( $false, $url ) {
if( !in_array( yourls_get_protocol( $url ), array( 'http://', 'https://' ) ) )
return $false;

if ( ozh_yourls_antispam_is_blacklisted( $url ) != false ) {
if ( ozh_yourls_antispam_is_blacklisted( $url ) === yourls_apply_filter( 'ozh_yourls_antispam_malformed', 'malformed' ) ) {
return array(
'status' => 'fail',
'code' => 'error:nourl',
'message' => yourls__( 'Missing or malformed URL' ),
'errorCode' => '400',
);
}

if ( ozh_yourls_antispam_is_blacklisted( $url ) != false ) {
return array(
'status' => 'fail',
'code' => 'error:spam',
'message' => 'This domain is blacklisted',
'errorCode' => '403',
);
}
}

// All clear, not interrupting the normal flow of events
return $false;
Expand Down

0 comments on commit bcb9b9f

Please sign in to comment.