Currently, the regex used by locale_language_from_browser() to match language strings will incorrectly match invalid language strings. As an example, the random 10-character string iecRswK4eh will incorrectly result in eh-oh-laa-laa because there is a numeral in the string, and the regex does not require that each string be preceeded by the beginning of the string or a comma (with optional whitespace).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pdrake’s picture

Status: Active » Needs review
FileSize
1.58 KB
Gábor Hojtsy’s picture

Issue tags: +D8MI, +sprint, +language-base

Looks good. It just adds a look-behind pattern before the existing pattern. Can you also submit just the test change so we can demonstrate it failing? Thanks!

pdrake’s picture

This patch includes both an added test for a comma-space separated set of languages which should pass (and the change continues to pass) as well as the test for the bad string, which should fail.

Status: Needs review » Needs work

The last submitted patch, core-failing_langage_test-1513520-3.patch, failed testing.

plach’s picture

Status: Needs work » Reviewed & tested by the community

Looks like this is RTBC. Patch to be committed in #1 (kudos ;)

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks.

plach’s picture

Version: 8.x-dev » 7.x-dev
Status: Fixed » Reviewed & tested by the community
FileSize
1.54 KB

Just applied the patch in #1 with -p2 and rerolled, thus setting back to RTBC.

pdrake’s picture

And here is a re-roll of #3 which should show the failure in D7.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, core-failing_langage_test-1513520-8.patch, failed testing.

pdrake’s picture

Status: Needs work » Reviewed & tested by the community

Since the patch in #8 was intended to fail - setting this back to RTBC (patch in #7).

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x. Thanks!

xjm’s picture

Title: locale_language_from_browser() incorrectly matches invalid strings » HEAD BROKEN: locale_language_from_browser() incorrectly matches invalid strings
Priority: Normal » Critical
Status: Fixed » Reviewed & tested by the community

The test-only patch from #8 was committed. We need a rollback, and/or just to commit the fix part from #7. :)

Gábor Hojtsy’s picture

Please commit the fix :)

webchick’s picture

Title: HEAD BROKEN: locale_language_from_browser() incorrectly matches invalid strings » locale_language_from_browser() incorrectly matches invalid strings
Status: Reviewed & tested by the community » Fixed

Doh. :( Core commit sprees after 1 am--;

xjm’s picture

Priority: Critical » Normal

Yay.

Tor Arne Thune’s picture

Gábor Hojtsy’s picture

Issue tags: -sprint

Thanks.

Status: Fixed » Closed (fixed)

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

cweagans’s picture

Issue tags: +Needs backport to D7