diff --git a/core/modules/editor/src/Form/EditorLinkDialog.php b/core/modules/editor/src/Form/EditorLinkDialog.php
index 4965cc5..a3c0c01 100644
--- a/core/modules/editor/src/Form/EditorLinkDialog.php
+++ b/core/modules/editor/src/Form/EditorLinkDialog.php
@@ -14,6 +14,11 @@
 use Drupal\Core\Ajax\HtmlCommand;
 use Drupal\editor\Ajax\EditorDialogSave;
 use Drupal\Core\Ajax\CloseModalDialogCommand;
+use Drupal\Component\Utility\UrlHelper;
+use Drupal\Core\Url;
+use Drupal\Core\ParamConverter\ParamNotConvertedException;
+use Drupal\Core\Routing\MatchingRouteNotFoundException;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
 /**
  * Provides a link dialog for text editors.
@@ -79,6 +84,46 @@ public function buildForm(array $form, FormStateInterface $form_state, FilterFor
   /**
    * {@inheritdoc}
    */
+  public function validateForm(array &$form, FormStateInterface $form_state) {
+    try {
+      $attr = $form_state->getValue('attributes');
+      $parsed_url = UrlHelper::parse($attr['href']);
+
+      // If internal links are supported, look up whether the given value is
+      // a path alias and store the system path instead.
+      if (!UrlHelper::isExternal($attr['href'])) {
+        $parsed_url['path'] = \Drupal::service('path.alias_manager')->getPathByAlias($parsed_url['path']);
+      }
+
+      $url = Url::createFromPath($parsed_url['path']);
+      $url->setOption('query', $parsed_url['query']);
+      $url->setOption('fragment', $parsed_url['fragment']);
+      $url->setOption('attributes', array('target' => $attr['target']));
+      $path = $url->toString();
+
+      // Reset the URL value to contain only the path.
+      $form_state->setValue('attributes', array('href' => $path, 'target' => $attr['target']));
+    }
+    catch (NotFoundHttpException $e) {
+      $form_state->setErrorByName('attributes', $this->t('Failed to save URL. The server reports the following message: !message', array(
+        '!message' => '<p class="error">' . $e->getMessage()  . '</p>',
+      )));
+    }
+    catch (MatchingRouteNotFoundException $e) {
+      $form_state->setErrorByName('attributes', $this->t('Failed to save URL. The server reports the following message: !message', array(
+        '!message' => '<p class="error">' . $e->getMessage()  . '</p>',
+      )));
+    }
+    catch (ParamNotConvertedException $e) {
+      $form_state->setErrorByName('attributes', $this->t('Failed to save URL. The server reports the following message: !message', array(
+        '!message' => '<p class="error">' . $e->getMessage()  . '</p>',
+      )));
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $response = new AjaxResponse();
 
