Page MenuHomePhabricator

unbound id not checked in array indexing
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

Run Check Syntax on:

timestamp[a]

Actual Results:

A check mark

Expected Results:

An error saying that a is unbound.

Discussion:

Unless there is a short-circuiting, most programming languages will evaluate a syntax object by evaluating all subsyntax first. This means: for <a>[<i>], instead of:

  • a-val = eval(<a>)
  • error if a-val is not an array
  • i-val = eval(<i>)
  • return a-val[i-val]

It should be done in this order instead:

  • a-val = eval(<a>)
  • i-val = eval(<i>)
  • error if a-val is not an array
  • return a-val[i-val]

By the way, Check Syntax (or, well-formedness checking) by running the filter with short-circuit disabled is very brittle. I hope to devise an algorithm soon to replace the current checking.

Event Timeline

Nullzero created this task.Nov 5 2019, 4:08 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 5 2019, 4:08 AM
Nullzero updated the task description. (Show Details)Nov 5 2019, 4:13 AM
Daimona added a subscriber: Daimona.Nov 6 2019, 9:03 AM

Somehow related to T237090, should be an easy fix.

By the way, Check Syntax (or, well-formedness checking) by running the filter with short-circuit disabled is very brittle

You can say that again! It's been the source of a ton of bugs.

Change 548968 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Always evaluate the offset when retrieving array elements

https://gerrit.wikimedia.org/r/548968

Daimona claimed this task.Nov 6 2019, 9:11 AM

Change 548968 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Always evaluate the offset when retrieving array elements

https://gerrit.wikimedia.org/r/548968

Daimona closed this task as Resolved.Dec 27 2019, 2:41 PM