diff --git a/core/includes/file.inc b/core/includes/file.inc
index 137dd0d..e659520 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -254,7 +254,7 @@ function file_stream_wrapper_get_class($scheme) {
  * Returns the scheme of a URI (e.g. a stream).
  *
  * @param $uri
- *   A stream, referenced as "scheme://target".
+ *   A stream, referenced as "scheme://target" or "data:target".
  *
  * @return
  *   A string containing the name of the scheme, or FALSE if none. For example,
@@ -263,8 +263,12 @@ function file_stream_wrapper_get_class($scheme) {
  * @see file_uri_target()
  */
 function file_uri_scheme($uri) {
-  $position = strpos($uri, '://');
-  return $position ? substr($uri, 0, $position) : FALSE;
+  if (preg_match('/^([\w\-]+):\/\/|^(data):/', $uri, $matches)) {
+    // The scheme will always be the last element in the matches array.
+    return array_pop($matches);
+  }
+
+  return FALSE;
 }
 
 /**
@@ -297,20 +301,21 @@ function file_stream_wrapper_valid_scheme($scheme) {
  * Returns the part of a URI after the schema.
  *
  * @param $uri
- *   A stream, referenced as "scheme://target".
+ *   A stream, referenced as "scheme://target" or "data:target".
  *
  * @return
- *   A string containing the target (path), or FALSE if none.
+ *   A string containing the target (path), or an empty string if none.
  *   For example, the URI "public://sample/test.txt" would return
  *   "sample/test.txt".
  *
  * @see file_uri_scheme()
  */
 function file_uri_target($uri) {
-  $data = explode('://', $uri, 2);
+  // Remove the scheme from the URI.
+  $target = preg_replace('/^[\w\-]+:\/\/|^data:/', '', $uri);
 
   // Remove erroneous leading or trailing, forward-slashes and backslashes.
-  return count($data) == 2 ? trim($data[1], '\/') : FALSE;
+  return trim($target), '\/');
 }
 
 /**
@@ -463,9 +468,9 @@ function file_create_url($uri) {
       return $GLOBALS['base_url'] . '/' . drupal_encode_path($uri);
     }
   }
-  elseif ($scheme == 'http' || $scheme == 'https') {
-    // Check for HTTP so that we don't have to implement getExternalUrl() for
-    // the HTTP wrapper.
+  elseif ($scheme == 'http' || $scheme == 'https' || $scheme == 'data') {
+    // Check for HTTP and data URI-encoded URLs so that we don't have to
+    // implement getExternalUrl() for the HTTP and data wrappers.
     return $uri;
   }
   else {
diff --git a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php
index 0763507..d8e0b6e 100644
--- a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php
@@ -106,6 +106,9 @@ function testFileCreateUrl() {
       $this->checkUrl('private', '', $basename, $base_url . '/' . $script_path . 'system/files/' . $basename_encoded);
     }
     $script_path = $script_path_original;
+
+    // Test a data URI.
+    $this->assertEqual(file_create_url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Generated URL matches expected URL.'));
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php b/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php
index f94d7b1..ca52f13 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/StreamWrapperTest.php
@@ -75,7 +75,10 @@ function testUriFunctions() {
 
     // Test file_uri_target().
     $this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
+    $this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.'));
     $this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
+    $this->assertFalse(file_uri_target('public://'), 'public:// has no target.');
+    $this->assertFalse(file_uri_target('data:'), 'data: has no target.');
 
     // Test file_build_uri() and
     // Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
@@ -92,6 +95,8 @@ function testUriFunctions() {
    */
   function testGetValidStreamScheme() {
     $this->assertEqual('foo', file_uri_scheme('foo://pork//chops'), 'Got the correct scheme from foo://asdf');
+    $this->assertEqual('data', file_uri_scheme('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'Got the correct scheme from a data URI.');
+    $this->assertFalse(file_uri_scheme('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
     $this->assertTrue(file_stream_wrapper_valid_scheme(file_uri_scheme('public://asdf')), 'Got a valid stream scheme from public://asdf');
     $this->assertFalse(file_stream_wrapper_valid_scheme(file_uri_scheme('foo://asdf')), 'Did not get a valid stream scheme from foo://asdf');
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php
index d3a090f..1216f65 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php
@@ -284,4 +284,15 @@ function testDrupalPreRenderLinks() {
     $this->assertIdentical(strpos($parent_html, 'First child link'), FALSE, '"First child link" link not found.');
     $this->assertIdentical(strpos($parent_html, 'Third child link'), FALSE, '"Third child link" link not found.');
   }
+
+  /**
+   * Tests theme_image().
+   */
+  function testImage() {
+    // Test that data URIs work with theme_image().
+    $variables = array();
+    $variables['uri'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
+    $expected = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="" />';
+    $this->assertThemeOutput('image', $variables, $expected);
+  }
 }
