Skip to content

fix(developer): tighten touch layout file structural validity checks - #16347

Merged
mcdurdin merged 2 commits into
masterfrom
fix/developer/16214-tighten-touch-layout-file-validity
Aug 20, 2026
Merged

fix(developer): tighten touch layout file structural validity checks#16347
mcdurdin merged 2 commits into
masterfrom
fix/developer/16214-tighten-touch-layout-file-validity

Conversation

@mcdurdin

@mcdurdin mcdurdin commented Aug 11, 2026

Copy link
Copy Markdown
Member

Fixes: #16214
Fixes: KEYMAN-DEVELOPER-39Q
Test-bot: skip

@keymanapp-test-bot

keymanapp-test-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

Comment on lines +275 to +293
// Transform the layout keys with displayMap
if(displayMap) {
Osk.remapTouchLayout(data, displayMap);
}

// If not debugging, then this strips out formatting for a big saving in file size
// This also normalises any values such as Pad or Width which should be strings
const writer = new TouchLayoutFileWriter({formatted: FDebug});

sLayoutFile = writer.compile(data);

sLayoutFile = TransformSpecialKeys14(FDebug, sLayoutFile);

sLayoutFile = TransformSpecialKeys17(FDebug, sLayoutFile);

return {
output: sLayoutFile,
result
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes to this code, just factored the validation out of this function to simplify test.

Fixes: #16214
Fixes: KEYMAN-DEVELOPER-39Q
Test-bot: skip
@mcdurdin
mcdurdin force-pushed the fix/developer/16214-tighten-touch-layout-file-validity branch from e56351a to cd674fd Compare August 12, 2026 05:27
@keyman-server keyman-server modified the milestones: A19S35, A19S36 Aug 17, 2026
@mcdurdin
mcdurdin requested a review from ermshiperete August 19, 2026 06:33

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be worth a function comment since the name is fairly similar to validateLayoutFileContent.

Comment on lines +364 to +365
if(typeof(key.flick) != "object") {
callbacks.reportMessage(KmwCompilerMessages.Error_InvalidTouchLayoutFileFormat({msg: 'platform.layer must be an array'}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the check is different, but the message is still the same as above?

assert.isNull(unitTestEndpoints.validateLayoutFileContent(fixture.data, []));
assert.isTrue(callbacks.hasMessage(KmwCompilerMessages.ERROR_InvalidTouchLayoutFileFormat));
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness we might want to add happy path tests as well. But that might be too complicated to setup, probably tested elsewhere and not worth doing here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, happy path tests are mostly covered I think in existing unit tests.

Rename `ValidateLayoutFile()` to `CompileLayoutFile()` to better reflect
the transform steps it performs, add documentation, and address review
comments.

Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>
@mcdurdin
mcdurdin merged commit e5ad777 into master Aug 20, 2026
9 checks passed
@mcdurdin
mcdurdin deleted the fix/developer/16214-tighten-touch-layout-file-validity branch August 20, 2026 14:27
@github-project-automation github-project-automation Bot moved this from Todo to Done in Keyman Aug 20, 2026
@keyman-server

Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 19.0.271-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(developer): Updating old project file: fatal KM02900: Unexpected exception: TypeError: row.key is not iterable

3 participants