Loading core/modules/system/src/Controller/EntityAutocompleteController.php +20 −18 Original line number Diff line number Diff line Loading @@ -79,8 +79,9 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha $matches = []; // Get the typed string from the URL, if it exists. if ($input = $request->query->get('q')) { $typed_string = Tags::explode($input); $typed_string = mb_strtolower(array_pop($typed_string)); $tag_list = Tags::explode($input); if (!empty($tag_list)) { $typed_string = mb_strtolower(array_pop($tag_list)); // Selection settings are passed in as a hashed key of a serialized array // stored in the key/value store. Loading @@ -101,6 +102,7 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string); } } return new JsonResponse($matches); } Loading core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,10 @@ public function testEntityReferenceAutocompletion() { 'label' => Html::escape($entity_3->name->value), ]; $this->assertSame($target, reset($data), 'Autocomplete returns an entity label containing a comma and a slash.'); $input = '"l!J>&Tw'; $data = $this->getAutocompleteResult($input); $this->assertSame([], $data, 'Autocomplete of invalid string returns empty result'); } /** Loading Loading
core/modules/system/src/Controller/EntityAutocompleteController.php +20 −18 Original line number Diff line number Diff line Loading @@ -79,8 +79,9 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha $matches = []; // Get the typed string from the URL, if it exists. if ($input = $request->query->get('q')) { $typed_string = Tags::explode($input); $typed_string = mb_strtolower(array_pop($typed_string)); $tag_list = Tags::explode($input); if (!empty($tag_list)) { $typed_string = mb_strtolower(array_pop($tag_list)); // Selection settings are passed in as a hashed key of a serialized array // stored in the key/value store. Loading @@ -101,6 +102,7 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string); } } return new JsonResponse($matches); } Loading
core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,10 @@ public function testEntityReferenceAutocompletion() { 'label' => Html::escape($entity_3->name->value), ]; $this->assertSame($target, reset($data), 'Autocomplete returns an entity label containing a comma and a slash.'); $input = '"l!J>&Tw'; $data = $this->getAutocompleteResult($input); $this->assertSame([], $data, 'Autocomplete of invalid string returns empty result'); } /** Loading