Review main Merged

82038[BUGFIX] Prevent endless loop in t3editor when using '/*' literal

Garvin Hicking CR +2 V +2 Easy +3 −3 updated 11/30/23, 08:43

Commit message

When entering the sequence "/*" into any t3editor instance
(i.e. TypoScript editor in the backend), it puts the browser in an
endless loop.

The reason is that the method `stream.next()` declares to either return
a string value or `void` (=`undefined`), but the code checks for `null`.
The check is now fixed and another cases where a loose null comparison
was used is adapted as well. Note that a loose null comparison between
null and undefined return equality, but a strict comparison doesn't.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Garvin Hicking +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Garvin Hicking +1
    • Andreas Kalkhoff +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1316

  1. Garvin Hicking uploaded patch set 1 11/29/23, 14:49

  2. Garvin Hicking commented on patch set 1 11/29/23, 14:54

    This is the implementation of Andreas Kalkhoffs idea posted on typo3-cms slack, I'll quote his remark here: (...) looking at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80852/2/Build/Sources/TypeScript/t3editor/stream-parser/typoscript.ts#1085 there's a small change to the function tokenComment(); I'd suspect that the null-check returns always true (given that "FALSE !== null" equals TRUE; though idk the return values of stream.next() ). I think going for != instead of !== might solve the issue. Please feel free to take over/abandon/change this patch as you like, I tried to do some legwork only.
  3. Andreas Kienast commented on patch set 1 CR -1 11/29/23, 14:55

    typoscript.ts:1077

    I don't understand how this should solve the issue. It smells like `stream.next()` returns anything that's falsey, not just `null`. This requires more debugging.
  4. core-ci voted on patch set 1 V +1 11/29/23, 14:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50123

  5. Andreas Kienast uploaded patch set 2 CR -1 V +1 11/29/23, 15:04

  6. Andreas Kienast commented on patch set 2 11/29/23, 15:04

    typoscript.ts:1077 Reply

    Done
  7. core-ci voted on patch set 2 V +1 11/29/23, 15:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50124

  8. Garvin Hicking commented on patch set 2 CR +1 V +1 11/29/23, 15:14

    One scenario left open, if I enter a typoscript line like: someString = '/* just a string' someOtherString = 'yes' then the highlight-parser thinks the "/*" started a comment that goes on also for the next line (and remains unclosed), while in reality it's just part of a string. (Can't comment on whether this has always been misinterpreted? At least this behaviour is better than crashing the browser, so I'm all for it)
  9. Benjamin Franzke commented on patch set 2 CR -1 11/29/23, 15:16

    thanks, good catch! will check (we've got other loops that look fishy as well)
  10. Andreas Kienast commented on patch set 2 11/29/23, 15:17

    Reply

    AFAICS that's a misbehavior caused by how the parser is implemented. It solely checks for matching tokens, ignoring the context a token was found in.
  11. Benjamin Franzke uploaded patch set 3 CR +1 V +1 11/30/23, 07:44

  12. core-ci voted on patch set 3 V +1 11/30/23, 07:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50149

  13. Garvin Hicking voted on patch set 3 CR +1 V +1 11/30/23, 08:10

  14. Andreas Kalkhoff voted on patch set 3 V +1 11/30/23, 08:34

  15. Andreas Kienast voted on patch set 3 CR +2 V +2 11/30/23, 08:36

  16. Andreas Kienast merged patch set 4 11/30/23, 08:43