This is hard to observe because of how bash handles newlines.
For example:
echo "$(echo -e " To {\n World\n \\\\\\\\\\\\\\{\n")"
Would produce a string where the slashes after world actually represent a total of 4 slashes.
The problem with bash is that it "guesses" the number of slashes.
Another concern is that there are two quotes, so a slash has to be escaped twice for such a string in bash.
As a more complex example, see:
# echo "$(echo -e "\\\\\\\\\\\\\\")" | byte_dump -tcw 5
Piped Byte Dump: (in Hexidecimal)
0000000000000000 5c 5c 5c 5c 0a | \\\\ |
# echo "$(echo -e "\\\\\\\\\\")" | byte_dump -tcw 5
Piped Byte Dump: (in Hexidecimal)
0000000000000000 5c 5c 5c 0a | \\\ |
Once past the confusing behavior of backslash escaping in Bash, one can then observe that this project is incorrectly escaping backslashes.
In the case of Embedded List close character (the close brace '}') only the first backslash needs to be escaped.
In the case of Embedded List open character (the open brace '{') every even backslash must be escaped (and there should only be a single unescaped odd backslash).
The problem is that the code is treating the close brace as an open brace, resulting in too many backslashes.
There is also an ends of EOL boolean that appears to be being incorrectly set.
The EOL is detected at range->start position, but the position is being reset to the saved "start" position.
}
else if (content.string[range->start] == f_fss_eol || range->start >= content.used || range->start > range->stop) {
- if (content.string[range->start] == f_fss_eol) {
- ends_on_eol = F_true;
- }
- else {
- ends_on_eol = F_false;
- }
-
- // increase by total slashes + 1, along with the extended list open and possible newline.
- status = private_fl_fss_destination_increase_by(slash_count + 3, destination);
+ // increase by total slashes + 1 embedded list open/close.
+ status = private_fl_fss_destination_increase_by(slash_count + 2, destination);
if (F_status_is_error(status)) break;
- while (slash_count--) {
- destination->string[destination->used++] = f_fss_delimit_slash;
- } // while
+ if (content.string[range->start] == f_fss_embedded_list_open) {
+ while (slash_count--) {
+ destination->string[destination->used++] = f_fss_delimit_slash;
+ } // while
+ }
destination->string[destination->used++] = f_fss_delimit_slash;
destination->string[destination->used++] = content.string[start];