add code to strip emoji from registration data when entered by user

This commit is contained in:
2017-09-08 23:04:57 +10:00
parent 258febf238
commit 0763037aec
2 changed files with 9 additions and 2 deletions

View File

@@ -1,5 +1,12 @@
<?php <?php
// $Id: booking.helper.inc,v 0.1 2011/07/12
/**
* Helper function to strip emoji characters from input text
* Taken from https://www.drupal.org/node/2043439#comment-8213973
*/
function _booking_remove_emoji($text){
return preg_replace('/([0-9|#][\x{20E3}])|[\x{00ae}|\x{00a9}|\x{203C}|\x{2047}|\x{2048}|\x{2049}|\x{3030}|\x{303D}|\x{2139}|\x{2122}|\x{3297}|\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F6FF}][\x{FE00}-\x{FEFF}]?/u', '', $text);
}
/** /**
* Helper function to perform some validity checking of email addresses * Helper function to perform some validity checking of email addresses

View File

@@ -291,7 +291,7 @@ function booking_insert($node) {
foreach ($node as $key => $value) { foreach ($node as $key => $value) {
//check if the key is a field that belongs in the database //check if the key is a field that belongs in the database
if ((strpos($key, "booking_") === 0) || $key === "nid") { if ((strpos($key, "booking_") === 0) || $key === "nid") {
$data[$key] = $value; $data[$key] = _booking_remove_emoji($value);
} }
} }
watchdog('booking_debug', "<pre>Inserting node:\n@info</pre>", array('@info' => print_r($data, TRUE))); watchdog('booking_debug', "<pre>Inserting node:\n@info</pre>", array('@info' => print_r($data, TRUE)));