You are here

function shurly_validate_custom in ShURLy 8

Same name and namespace in other branches
  1. 6 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

3 calls to shurly_validate_custom()
ShurlyCreateForm::validateForm in src/Form/ShurlyCreateForm.php
Form validation handler.
ShurlySubscriber::shurlyOnRespond in src/ShurlySubscriber.php
shurly_shorten in ./shurly.module
API function to shorten a URL.

File

./shurly.module, line 335
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;.
  return preg_match('/[\\/#%&\\@\\*\\{\\}\\:\\;<>\\?\\+ \\.\\,\'\\"\\$\\|`^\\[\\]]/u', $custom) ? FALSE : TRUE;
}