Hello,
the block_example.module file contains block_example_block_view_alter function to provide example of the hook operations. In it a string search is performed using stristr.

Using multibyte string operations is currently best practice. The patch attached fixes that.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tassos created an issue. See original summary.

tassos’s picture

Mile23’s picture

Status: Active » Needs review
Mile23’s picture

Status: Needs review » Needs work
+++ b/block_example/block_example.module
@@ -42,7 +42,7 @@ use Drupal\Core\Block\BlockPluginInterface;
-  if ((!empty($build['#configuration']['label']) && stristr($build['#configuration']['label'], 'uppercase')) || (!empty($definition['subject']) && stristr($definition['subject'], 'uppercase'))) {
+  if ((!empty($build['#configuration']['label']) && mb_stristr($build['#configuration']['label'], 'uppercase')) || (!empty($definition['subject']) && mb_stristr($definition['subject'], 'uppercase'))) {

Nice catch on multibyte, but it looks like we're only ever using this for logic and not to get the string back. Therefore we should use Unicode::strpos().

vaibhavjain’s picture

Status: Needs work » Needs review
FileSize
998 bytes

Attaching updated patch.
No Interdiff attached, as it was not required.

  • Mile23 committed 8ee1a98 on 8.x-1.x authored by tassos
    Issue #2628916 by tassos, vaibhavjain: Block example does not use...
Mile23’s picture

Status: Needs review » Fixed

Thanks!

Mile23’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.