libxkbcommon
libxkbcommon copied to clipboard
Compose parser is too lenient
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.
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
- If no valid sequences at all at the end, error.
- 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?
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