Skip to content

Commit

Permalink
Sanitize UTF-8 before adding it to the database
Browse files Browse the repository at this point in the history
  • Loading branch information
ximion committed Dec 8, 2023
1 parent 8dc8e62 commit aa355cd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/asgen/datastore.d
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ public:
private MDB_val makeDbValue (string data)
{
import core.stdc.string : strlen;
import std.encoding : sanitize, EncodingSchemeUtf8;

auto dataSane = sanitize(data);
auto cdata = dataSane.toStringz();

MDB_val mval;
auto cdata = data.toStringz();
mval.mv_size = char.sizeof * strlen(cdata) + 1;
mval.mv_data = cast(void*) cdata;
return mval;
Expand Down

0 comments on commit aa355cd

Please sign in to comment.