Line data Source code
1 : /*
2 : This file is part of TALER
3 : (C) 2025 Taler Systems SA
4 :
5 : TALER is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU Lesser General Public License as published by the Free Software
7 : Foundation; either version 3, or (at your option) any later version.
8 :
9 : TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 : WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 : A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 :
13 : You should have received a copy of the GNU General Public License along with
14 : TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15 : */
16 : /**
17 : * @file validators.c
18 : * @brief Input validators
19 : * @author Christian Grothoff
20 : */
21 : #include "platform.h"
22 : #include <gnunet/gnunet_util_lib.h>
23 : #include <gnunet/gnunet_db_lib.h>
24 : #include <taler/taler_json_lib.h>
25 : #include "taler_merchant_util.h"
26 :
27 :
28 : bool
29 75 : TALER_MERCHANT_image_data_url_valid (const char *image_data_url)
30 : {
31 75 : if (0 == strcmp (image_data_url,
32 : ""))
33 23 : return true;
34 52 : if (0 != strncasecmp ("data:image/",
35 : image_data_url,
36 : strlen ("data:image/")))
37 : {
38 0 : GNUNET_break_op (0);
39 0 : return false;
40 : }
41 52 : if (NULL == strstr (image_data_url,
42 : ";base64,"))
43 : {
44 0 : GNUNET_break_op (0);
45 0 : return false;
46 : }
47 52 : if (! TALER_url_valid_charset (image_data_url))
48 : {
49 0 : GNUNET_break_op (0);
50 0 : return false;
51 : }
52 52 : return true;
53 : }
|