Page MenuHomePhabricator

EasyTimeline error when "(24)" is inserted: "Unknown constant. 'Define $29 = ... ' expected."
Closed, ResolvedPublic

Description

Hello,

I've noticed that EasyTimeline fails when I add (24) (including brackets) to the timeline. See https://cs.wikipedia.org/w/index.php?title=Wikipedista:Martin_Urbanec/P%C3%ADskovi%C5%A1t%C4%9B/4&oldid=17470355 as an example .This edit does fix that, but I don't see a reason why (24) should be banned.

Martin

Event Timeline

Disclaimer: I'm not a developer so I might be wrong.

  1. U+0024 is $.
  2. There is [my $hDollar = &EncodeInput("\$");](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$129)
  3. In [if ($Line !~ /^\s*$/) {](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$568), $Line is from: 0 till: 24 color:orange text:"[[Írán]]" (24)
  4. We hit [$Line = &EncodeInput($Line);](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$569).
  5. We enter the [EncodeInput](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$5174) subroutine.
  6. We run [$text =~ s/([\`\{\}\%\&\@\$\(\)\;\=])/"%" . sprintf ("%X", ord($1)) . "%";/ge;](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$5180) and $Line becomes from: 0 till: 24 color:orange text:"[[Írán]]" %28%24%29%
  7. We hit [$Line =~ s/($hDollar[a-zA-Z0-9]+)/&GetDefine($Line,$1)/ge;](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$572). Our string includes %24 due to encoding the opening bracket.
  8. We match the regex about $hDollar and get into the [GetDefine](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$703) subroutine.
  9. In [$const = lc($const);](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$706) , $const = %24%29
  10. In [my $value = $Consts{ lc($const) };](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$707), $value remains undefined
  11. We bail out in [if (!defined($value)) { &Error("Unknown constant. 'Define $const = ... ' expected."); return ($const); }](https://phabricator.wikimedia.org/diffusion/ETLN/browse/master/EasyTimeline.pl$708)

I'd recommend to use the Graph extension instead of the EasyTimeline extension. Or to fix the regex in step 6.

Aklapper renamed this task from EasyTimeline bugs when (24) is inserted to EasyTimeline error when "(24)" is inserted: "Unknown constant. 'Define $29 = ... ' expected.".Jul 11 2019, 8:44 PM

Change #1053073 had a related patch set uploaded (by Pppery; author: Pppery):

[mediawiki/extensions/timeline@master] Parse $Define calls before encodeInput so that (24) isn't encoded and mangled

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

Change #1053073 merged by jenkins-bot:

[mediawiki/extensions/timeline@master] Parse $Define calls before encodeInput so that (24) isn't encoded and mangled

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

Pppery closed this task as Resolved.EditedJul 30 2024, 7:32 PM

This will be deployed the week of August 6-8.