Closed Bug 1801690 Opened 1 year ago Closed 1 year ago

indexOf function doesn't work correctly with polish letters

Categories

(Core :: JavaScript: Standard Library, defect)

Firefox 107
x86_64
Windows 10
defect

Tracking

()

VERIFIED FIXED
109 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox107 --- wontfix
firefox108 --- verified
firefox109 --- verified

People

(Reporter: drukowanie.lobo, Assigned: alexical)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Steps to reproduce:

Demo: https://codesandbox.io/s/suspicious-euler-flddq6?file=/src/index.js:0-729

const alpha = Array.from(Array(26)).map((e, i) => i + 65);
const alphabet = [
...alpha.map((x) => String.fromCharCode(x)),
...alpha.map((x) => String.fromCharCode(x).toUpperCase())
];

const polishLetters = (
"ą,ć,ę,ł,ń,ó,ś,ź,ż," + "ą,ć,ę,ł,ń,ó,ś,ź,ż".toUpperCase()
).split(",");

const result = [];

alphabet.forEach((letter) => {
polishLetters.forEach((pLetter) => {
alphabet.forEach((sLetter) => {
const toCheck = letter + sLetter;
const wrongResult = letter + pLetter;
if (toCheck.indexOf(wrongResult) === 0) {
result.push(${toCheck} === ${wrongResult}\n);
}
});
});
});

console.log(
[...new Set(result)].toString().replaceAll(",", "")
);

Actual results:

console output is:
AB === Ał
AD === Ań
AA === AŁ
AC === AŃ
AZ === AŚ
BB === Bł
BD === Bń
BA === BŁ
BC === BŃ
BZ === BŚ
CB === Cł
CD === Cń
CA === CŁ
CC === CŃ
CZ === CŚ
DB === Dł
DD === Dń
DA === DŁ
DC === DŃ
DZ === DŚ
EB === Eł
ED === Eń
EA === EŁ
EC === EŃ
EZ === EŚ
FB === Fł
FD === Fń
FA === FŁ
FC === FŃ
FZ === FŚ
GB === Gł
GD === Gń
GA === GŁ
GC === GŃ
GZ === GŚ
HB === Hł
HD === Hń
HA === HŁ
HC === HŃ
HZ === HŚ
IB === Ił
ID === Iń
IA === IŁ
IC === IŃ
IZ === IŚ
JB === Jł
JD === Jń
JA === JŁ
JC === JŃ
JZ === JŚ
KB === Kł
KD === Kń
KA === KŁ
KC === KŃ
KZ === KŚ
LB === Lł
LD === Lń
LA === LŁ
LC === LŃ
LZ === LŚ
MB === Mł
MD === Mń
MA === MŁ
MC === MŃ
MZ === MŚ
NB === Nł
ND === Nń
NA === NŁ
NC === NŃ
NZ === NŚ
OB === Oł
OD === Oń
OA === OŁ
OC === OŃ
OZ === OŚ
PB === Pł
PD === Pń
PA === PŁ
PC === PŃ
PZ === PŚ
QB === Qł
QD === Qń
QA === QŁ
QC === QŃ
QZ === QŚ
RB === Rł
RD === Rń
RA === RŁ
RC === RŃ
RZ === RŚ
SB === Sł
SD === Sń
SA === SŁ
SC === SŃ
SZ === SŚ
TB === Tł
TD === Tń
TA === TŁ
TC === TŃ
TZ === TŚ
UB === Uł
UD === Uń
UA === UŁ
UC === UŃ
UZ === UŚ
VB === Vł
VD === Vń
VA === VŁ
VC === VŃ
VZ === VŚ
WB === Wł
WD === Wń
WA === WŁ
WC === WŃ
WZ === WŚ
XB === Xł
XD === Xń
XA === XŁ
XC === XŃ
XZ === XŚ
YB === Ył
YD === Yń
YA === YŁ
YC === YŃ
YZ === YŚ
ZB === Zł
ZD === Zń
ZA === ZŁ
ZC === ZŃ
ZZ === ZŚ

Expected results:

Console output should be empty string

(In reply to lobo from comment #0)

Steps to reproduce:

Demo: https://codesandbox.io/s/suspicious-euler-flddq6?file=/src/index.js:0-729

const alpha = Array.from(Array(26)).map((e, i) => i + 65);
const alphabet = [
...alpha.map((x) => String.fromCharCode(x)),
...alpha.map((x) => String.fromCharCode(x).toUpperCase())
];

const polishLetters = (
"ą,ć,ę,ł,ń,ó,ś,ź,ż," + "ą,ć,ę,ł,ń,ó,ś,ź,ż".toUpperCase()
).split(",");

const result = [];

alphabet.forEach((letter) => {
polishLetters.forEach((pLetter) => {
alphabet.forEach((sLetter) => {
const toCheck = letter + sLetter;
const wrongResult = letter + pLetter;
if (toCheck.indexOf(wrongResult) === 0) {
result.push(${toCheck} === ${wrongResult}\n);
}
});
});
});

console.log(
[...new Set(result)].toString().replaceAll(",", "")
);

Actual results:

console output is:
AB === Ał
AD === Ań
AA === AŁ
AC === AŃ
AZ === AŚ
BB === Bł
BD === Bń
BA === BŁ
BC === BŃ
BZ === BŚ
CB === Cł
CD === Cń
CA === CŁ
CC === CŃ
CZ === CŚ
DB === Dł
DD === Dń
DA === DŁ
DC === DŃ
DZ === DŚ
EB === Eł
ED === Eń
EA === EŁ
EC === EŃ
EZ === EŚ
FB === Fł
FD === Fń
FA === FŁ
FC === FŃ
FZ === FŚ
GB === Gł
GD === Gń
GA === GŁ
GC === GŃ
GZ === GŚ
HB === Hł
HD === Hń
HA === HŁ
HC === HŃ
HZ === HŚ
IB === Ił
ID === Iń
IA === IŁ
IC === IŃ
IZ === IŚ
JB === Jł
JD === Jń
JA === JŁ
JC === JŃ
JZ === JŚ
KB === Kł
KD === Kń
KA === KŁ
KC === KŃ
KZ === KŚ
LB === Lł
LD === Lń
LA === LŁ
LC === LŃ
LZ === LŚ
MB === Mł
MD === Mń
MA === MŁ
MC === MŃ
MZ === MŚ
NB === Nł
ND === Nń
NA === NŁ
NC === NŃ
NZ === NŚ
OB === Oł
OD === Oń
OA === OŁ
OC === OŃ
OZ === OŚ
PB === Pł
PD === Pń
PA === PŁ
PC === PŃ
PZ === PŚ
QB === Qł
QD === Qń
QA === QŁ
QC === QŃ
QZ === QŚ
RB === Rł
RD === Rń
RA === RŁ
RC === RŃ
RZ === RŚ
SB === Sł
SD === Sń
SA === SŁ
SC === SŃ
SZ === SŚ
TB === Tł
TD === Tń
TA === TŁ
TC === TŃ
TZ === TŚ
UB === Uł
UD === Uń
UA === UŁ
UC === UŃ
UZ === UŚ
VB === Vł
VD === Vń
VA === VŁ
VC === VŃ
VZ === VŚ
WB === Wł
WD === Wń
WA === WŁ
WC === WŃ
WZ === WŚ
XB === Xł
XD === Xń
XA === XŁ
XC === XŃ
XZ === XŚ
YB === Ył
YD === Yń
YA === YŁ
YC === YŃ
YZ === YŚ
ZB === Zł
ZD === Zń
ZA === ZŁ
ZC === ZŃ
ZZ === ZŚ

Expected results:

Console output should be empty string

OS: Unspecified → Windows 10
Hardware: Unspecified → x86_64
Component: Untriaged → General

16:06.68 INFO: Downloading build from: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/L4lKmU8UThWSKVsT1OpDuA/runs/0/artifacts/public%2Fbuild%2Ftarget.tar.bz2
===== Downloaded 100% =====
16:41.20 INFO: Running autoland build built on 2022-07-18 01:13:21.036000, revision bcfc4b4d
16:48.73 INFO: Launching /tmp/tmpremk5nr6/firefox/firefox
16:48.73 INFO: Application command: /tmp/tmpremk5nr6/firefox/firefox -profile /tmp/tmppm82ouwr.mozrunner
16:48.73 INFO: application_buildid: 20220714184827
16:48.73 INFO: application_changeset: bcfc4b4d52b90e90ba3f88fa7b91ce1cd9993767
16:48.73 INFO: application_name: Firefox
16:48.73 INFO: application_repository: https://hg.mozilla.org/integration/autoland
16:48.73 INFO: application_version: 104.0a1
Was this integration build good, bad, or broken? (type 'good', 'bad', 'skip', 'retry', 'back' or 'exit' and press Enter): bad
16:58.66 INFO: Narrowed integration regression window from [0f614ef6, 0ec8d087] (3 builds) to [0f614ef6, bcfc4b4d] (2 builds) (~1 steps left)
16:58.66 INFO: No more integration revisions, bisection finished.
16:58.66 INFO: Last good revision: 0f614ef65bc236875acf64f63f3b56c38fca5b31
16:58.66 INFO: First bad revision: bcfc4b4d52b90e90ba3f88fa7b91ce1cd9993767
16:58.66 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=0f614ef65bc236875acf64f63f3b56c38fca5b31&tochange=bcfc4b4d52b90e90ba3f88fa7b91ce1cd9993767

[rdk@on ~]$

Flags: needinfo?(dothayer)

I was able to reproduce this issue on our end as well in our latest Nightly build, Beta as well as Release.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Component: General → JavaScript: Standard Library
Ever confirmed: true
Product: Firefox → Core
Regressed by: 1776013
Assignee: nobody → dothayer
Status: NEW → ASSIGNED
Flags: needinfo?(dothayer)
Pushed by dothayer@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8f68e704f8fd
Fix searching for 2 wide chars in a latin1 string r=iain
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch

Verified as fixed in our latest Nightly build 109.0a1 (2022-11-23).

The patch landed in nightly and beta is affected.
:dthayer, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox108 to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(dothayer)

Comment on attachment 9304762 [details]
Bug 1801690 - Fix searching for 2 wide chars in a latin1 string r?iain

Beta/Release Uplift Approval Request

  • User impact if declined: Checking a string for the presence of a two-character sequence could under very specific circumstances yield a false positive.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): It's basically a one-liner which is pretty trivial to assess for correctness.
  • String changes made/needed:
  • Is Android affected?: Yes
Flags: needinfo?(dothayer)
Attachment #9304762 - Flags: approval-mozilla-beta?

Comment on attachment 9304762 [details]
Bug 1801690 - Fix searching for 2 wide chars in a latin1 string r?iain

Approved for 108.0b8

Attachment #9304762 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Verified as fixed in our latest Beta build 108.0b8.

Updating the Main Status flag.

Status: RESOLVED → VERIFIED
Duplicate of this bug: 1803869
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: