Inconsistent language handling allows duplicate source paths

Created on 9 June 2025, about 11 hours ago

Problem/Motivation

It is possible to create redirects with the same source url that point to different nodes. This leads to unexpected / confusing redirect results.

This happens because the language code values used in the hash are inconsistent between the code that handles adding redirects on alias changes and the Add Redirect form.

Redirects added by alias changes on a single language site (not tested on a multi lang site) use the language from the alias record. This is the default site language, e.g. 'en'. Done in the .module update alias code.

If you add a record via the add redirect form, the language code used is based on the form language which is 'und' on single language sites. This generates a different hash than the alias change hash. This bypasses the formValidate hash check and allows to Redirect entries to created with the same path.

Steps to reproduce

  • Turn on the Automatically create redirect when aliases are changed option
  • create a node with the alias /foo
  • Edit the node and change the alias to /bar
  • Go to the add Redirect form
  • Enter the source redirect as /foo
  • Select a different node as the destination
  • In the redirect listing page enter 'foo' in the from filter and filter by this
  • There will now be two entries for the /foo url pointing to different nodes.

Proposed resolution

Need to standardize how the default language is defined. Not sure of the best way to do this.

Possibly check for single language sites in the RedirectForm code and use the site language instead of und.

This will generate identical hashes.

Will need to have code to update the language and hash setting for existing redirects. Change only internal redirects?

An alternative might be:

Check for duplicate redirect_source_path field that have 'und' or the default language set and consider these duplicates in addition to the hash test.

This would keep from doing any updates to existing redirects.

Remaining tasks

Decide on best method.

What updates, if any, need to happen.

Write code

User interface changes

API changes

Data model changes

Decide

πŸ“Œ Task
Status

Active

Version

1.11

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cgmonroe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024