Page MenuHomePhabricator

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

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

Urbanecm created this task.Jul 11 2019, 3:52 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 11 2019, 3:52 PM

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