You are here

function shurly_validate_custom in ShURLy 6

Same name and namespace in other branches
  1. 8 shurly.module \shurly_validate_custom()
  2. 7 shurly.module \shurly_validate_custom()

Validate custom short URL string

Return value

TRUE if valid, FALSE if invalid

2 calls to shurly_validate_custom()
shurly_create_form_validate in ./shurly.module
shurly_shorten in ./shurly.module
API function to shorten a URL @arg $long_url - the long URL to shorten @arg $custom - optional custom short URL, user_access('enter custom URLs') should be checked prior to calling shurly_shorten()

File

./shurly.module, line 585
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function shurly_validate_custom($custom) {

  // check the length of the string
  if (strlen($custom) == 0) {
    return FALSE;
  }

  // disallow: #%&@*{}\:;<>?/+.,'"$|`^[] and space character
  return preg_match('/[\\/#%&\\@\\*\\{\\}\\:\\;<>\\?\\+ \\.\\,\'\\"\\$\\|`^\\[\\]]/u', $custom) ? FALSE : TRUE;
}