Url::fromRoute does not understand Russian characters in the query option

Created on 4 July 2015, almost 10 years ago
Updated 15 May 2025, 1 day ago

Code:

        \Drupal::service('link_generator')->generate($title, Url::fromRoute('yarcom_sphinx.search_type', array('search_type' => $t), array(
          'set_active_class' => TRUE,
          'query' => array(
            'q' => $i['query'],
          ),
        )));

If $i['query'] is russian characters, css class is-active does not appear.

Example 1:
$i['query'] = 'комацу' (russian characters).
Browser address bar: http://dev.******.ru/search/yarcom_news?q=%D0%BA%D0%BE%D0%BC%D0%B0%D1%86...
Html code:
<a href="/search/yarcom_news?q=%D0%BA%D0%BE%D0%BC%D0%B0%D1%86%D1%83" data-drupal-link-query="{&quot;q&quot;:&quot;\u043a\u043e\u043c\u0430\u0446\u0443&quot;}" data-drupal-link-system-path="search/yarcom_news">News entity</a>

Example 2:
$i['query'] = 'komatsu' (english characters).
Browser address bar: http://dev.*****.ru/search/yarcom_news?q=komatsu
Html code:
<a <strong>class="is-active"</strong> href="/search/yarcom_news?q=komatsu" data-drupal-link-query="{&quot;q&quot;:&quot;komatsu&quot;}" data-drupal-link-system-path="search/yarcom_news">News entity</a>

In the first example q=%D0%BA%D0%BE%D0%BC%D0%B0%D1%86%D1%83" and data-drupal-link-query="{"q":"\u043a\u043e\u043c\u0430\u0446\u0443"}" are not identical.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

system.module

Created by

🇷🇺Russia Sky Cat

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia mstrelan

    This needs an issue summary update, let's start with the standard issue template. I think it's also not clear from the title what is the bug that needs fixing, i.e. the is-active class is not added. Let's get 2525830-18-комацу.patch converted to an MR so we can see the test fail, then we can work on a fix for this.

  • 🇺🇸United States tr Cascadia
  • Pipeline finished with Failed
    about 5 hours ago
    Total: 117s
    #498569
  • 🇦🇺Australia mstrelan

    The test results in #18 demonstrated the bug for many years, until patch testing got turned off.

    I'm not disputing that, just trying to help make it easier for anyone interested in picking this up. Without this it's hard to know at a glance if anything has changed in core that might have fixed this over the last 5 years.

  • Pipeline finished with Failed
    about 2 hours ago
    #498618
  • 🇺🇸United States tr Cascadia

    Updated issue summary.

Production build 0.71.5 2024