Syrius: v0.0.6 metadata string escaping


The build fails when merging a branch.

ERROR: lib/utils/metadata.dart:3:33: Error: Expected ';' after this.
ERROR: const String gitCommitMessage = 'Merge branch 'master' into branch-x';


The build fails when one of the git variables contains special or escape characters like single quotes or \t.

The variables in the metadata.dart file are generated by scripts during the build. Having special characters in the git variables results in an incorrect variable declaration.

Single quotes are used by gitHub when merging a branch, which will generate the following incorrect variable declartion.

// Incorrect variable declaration
const String gitBranchName = 'Merge branch 'master' into branch-x';
const String gitCommitMessage = 'Char test `~!@#$%^&*\t()_+-={}[]:";'|\<>?,./';


By using raw strings, the escape characters are not interpreted and only single quotes need to be replaced with '"'"r'.

// Correct variable declaration
const String gitBranchName = r'Merge branch '"'"r'master'"'"r' into branch-x';
const String gitCommitMessage = r'Char test `~!@#$%^&*\t()_+-={}[]:";'"'"r'|\<>?,./';



You do a great job of documenting these bugs. I hope this becomes the example for others. I’ll try to incorporate these concepts into the contribution guideline I want to draft.

1 Like

@0x3639 Thanks, for bugs it’s simple and effective.

I’ve created a fix for the Linux and Windows scripts. I’m not sure how the MacOS build creates the metadata. You might want to look at it.

Both scripts now support all special characters. I’ve tested them both on my repository.


Just did a test with commit with message Special char test ~!@#$%^&*()_+``-=:";'\|[]{}<>?,./

Only macos is not building correctly.

lib/utils/metadata.dart:3:57: Error: A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).

[87]( adding a backslash (\) to escape the '$'.

[88]( String gitCommitMessage = 'Special char test ~!@#$%^&*()_+`-=:";'\|[]{}<>?,./';

Replacement of the $ with \$ seems to working differently under macos. Any thoughts?

@CryptoFish please check:

1 Like

I thought the MacOS build used the Linux bash script, but a copy was hidden somewhere in the project.pbxproj file. All three builds are working now and are now using raw strings, which only requires the single quotes to be replaced.


@0x3639 Maybe this is something you could use for the contribution guidelines.

1 Like

Great example. I’ll combine this with the Bitcoin guideline we found too. thx for sharing.

1 Like