libxkbcommon icon indicating copy to clipboard operation
libxkbcommon copied to clipboard

Compose parser is too lenient

Open wismill opened this issue 10 months ago • 2 comments

The following file parses correctly, although no sequence is valid!

! include ~
! include x
! include ""
include
include !
include x
# include ""
:
a :
: a
<a> : a a
!:
<a> : !

We should fail at least on the includes.

Found while looking for a Compose compile failure in #360.

wismill avatar Jan 30 '25 07:01 wismill

There is a max of 10 errors:

https://github.com/xkbcommon/libxkbcommon/blob/502e9e5bff3781cba09f3b33ec030522b549f4e5/src/compose/parser.c#L575

If I understand, you're thinking

  1. If no valid sequences at all at the end, error.
  2. If include fails, fail fast.

(1) sounds sensible to me. (2) might be a backward compat issue though. I can imagine people having some bad includes which they ignore but now the file will stop loading. But maybe it's OK to break?

bluetech avatar Jan 30 '25 08:01 bluetech

The are two issues with includes here:

  • bad syntax: it should fail early. We may be lenient for some other syntax issues, but I think we should not for includes.
  • file not found: skip and emit an error

wismill avatar Jan 30 '25 08:01 wismill