From d6724f5a06b37b1ee8ca36f5f1cbea048a311abe Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Wed, 8 Feb 2017 12:50:41 +0000
Subject: [PATCH] Issue #1569894 by sun, alexpott: Update unicode.inc to PHP5

---
 core/includes/unicode.inc                                | 5 +++++
 core/modules/aggregator/src/Form/OpmlFeedAdd.php         | 3 ++-
 core/modules/aggregator/src/Tests/AggregatorTestBase.php | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/core/includes/unicode.inc b/core/includes/unicode.inc
index f0df33ede2cb..b09ddb765fef 100644
--- a/core/includes/unicode.inc
+++ b/core/includes/unicode.inc
@@ -74,6 +74,11 @@ function unicode_requirements() {
  *   An XML parser object or FALSE on error.
  *
  * @ingroup php_wrappers
+ *
+ * @deprecated in Drupal 8.3.0 and will bre removed in Drupal 9.0.0. Use
+ *   xml_parser_create() and
+ *   xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8')
+ *   instead.
  */
 function drupal_xml_parser_create(&$data) {
   // Default XML encoding is UTF-8
diff --git a/core/modules/aggregator/src/Form/OpmlFeedAdd.php b/core/modules/aggregator/src/Form/OpmlFeedAdd.php
index 0ba285a9548c..c78a8b73acc2 100644
--- a/core/modules/aggregator/src/Form/OpmlFeedAdd.php
+++ b/core/modules/aggregator/src/Form/OpmlFeedAdd.php
@@ -190,7 +190,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
    */
   protected function parseOpml($opml) {
     $feeds = array();
-    $xml_parser = drupal_xml_parser_create($opml);
+    $xml_parser = xml_parser_create();
+    xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8');
     if (xml_parse_into_struct($xml_parser, $opml, $values)) {
       foreach ($values as $entry) {
         if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) {
diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php
index 15be1448bc71..9d5899d0b20b 100644
--- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php
+++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php
@@ -271,7 +271,8 @@ public function getValidOpml(array $feeds) {
 EOF;
 
     $path = 'public://valid-opml.xml';
-    return file_unmanaged_save_data($opml, $path);
+    // Add the UTF-8 byte order mark.
+    return file_unmanaged_save_data(chr(239) . chr(187) . chr(191) . $opml, $path);
   }
 
   /**
-- 
GitLab