diff --git a/includes/objects/contribution.php b/includes/objects/contribution.php index 9818f7db0..15a41ac63 100644 --- a/includes/objects/contribution.php +++ b/includes/objects/contribution.php @@ -1091,6 +1091,13 @@ public function set_demo_url($branch, $url) */ public function submit() { + // Emojis and other four byte characters are not allowed by MySQL in the + // utf8 column the name is stored in, so replace them with their numeric + // character reference, as core does for report text. Doing it here keeps + // the encoded form out of everything that reads the name, including the + // release topic subject and the generated slug. + $this->contrib_name = utf8_encode_ucr($this->contrib_name); + if (!$this->contrib_id) { // Make sure the author exists, if not we create one (do this before returning if not approved...else we need to duplicate this code in a bunch of places) diff --git a/url/url.php b/url/url.php index df8fbac38..0b7b995ec 100644 --- a/url/url.php +++ b/url/url.php @@ -192,6 +192,13 @@ public function remove_nth_param($nth) */ public static function generate_slug($string) { + // Neither a character reference nor a character outside the basic + // multilingual plane belongs in a slug: the columns slugs are stored in + // are utf8, which cannot hold the latter, and the digits of the former + // would end up in the URL. + $string = preg_replace('/&#[0-9]+;/', '', $string); + $string = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $string); + $string = self::url_replace($string, false); // Replace any number of spaces with a single underscore