mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:23:24 +00:00
Fix the dive site XML saving
It turns out that the dive site saving was subtly but horribly buggy. To save the value of the dive site, it did show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize); which looks sane on the face of it, but the problem is that it puts the final closing xml marker in the 'append this at the end' case. That means that if the value is empty, the value won't be saved, but neither will the closing tag. Resulting in an xml line that looks like this: <geo cat='3' origin='0' <geo cat='5' origin='0' value='Other name'/> where the first geo tag was saved without the ending marker. That then makes all the xml nesting entirely wrong, and the whole file fails to save. Now, the code around it does check that 't->value' is not NULL, but it doesn't check for a value that is empty or all spaces (which also will make 'show_utf8()' just skip it. Fix it by saving the end marker separately: show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize); put_format(b, "/>\n"); so that the xml is valid even if the goe marker value wasn'r. Reported-by: Bob Barker <barkerb1965@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5ffca686c2
commit
8c408da9ab
1 changed files with 4 additions and 2 deletions
|
@ -623,7 +623,8 @@ void save_dives_buffer(struct membuffer *b, const bool select_only, bool anonymi
|
|||
if (t->category != TC_NONE && t->value) {
|
||||
put_format(b, " <geo cat='%d'", t->category);
|
||||
put_format(b, " origin='%d'", t->origin);
|
||||
show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize);
|
||||
show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
|
||||
put_format(b, "/>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -837,7 +838,8 @@ void save_dive_sites_buffer(struct membuffer *b, const bool select_only, bool an
|
|||
if (t->category != TC_NONE && t->value) {
|
||||
put_format(b, " <geo cat='%d'", t->category);
|
||||
put_format(b, " origin='%d'", t->origin);
|
||||
show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize);
|
||||
show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
|
||||
put_format(b, "/>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue