LCOV - code coverage report
Current view: top level - shared - web-util.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 16 26 61.5 %
Date: 2019-08-22 15:41:25 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #include <stdbool.h>
       4             : 
       5             : #include "string-util.h"
       6             : #include "strv.h"
       7             : #include "utf8.h"
       8             : #include "web-util.h"
       9             : 
      10           0 : bool http_etag_is_valid(const char *etag) {
      11           0 :         if (isempty(etag))
      12           0 :                 return false;
      13             : 
      14           0 :         if (!endswith(etag, "\""))
      15           0 :                 return false;
      16             : 
      17           0 :         if (!STARTSWITH_SET(etag, "\"", "W/\""))
      18           0 :                 return false;
      19             : 
      20           0 :         return true;
      21             : }
      22             : 
      23          56 : bool http_url_is_valid(const char *url) {
      24             :         const char *p;
      25             : 
      26          56 :         if (isempty(url))
      27           0 :                 return false;
      28             : 
      29         163 :         p = STARTSWITH_SET(url, "http://", "https://");
      30          56 :         if (!p)
      31          52 :                 return false;
      32             : 
      33           4 :         if (isempty(p))
      34           0 :                 return false;
      35             : 
      36           4 :         return ascii_is_valid(p);
      37             : }
      38             : 
      39          57 : bool documentation_url_is_valid(const char *url) {
      40             :         const char *p;
      41             : 
      42          57 :         if (isempty(url))
      43           1 :                 return false;
      44             : 
      45          56 :         if (http_url_is_valid(url))
      46           4 :                 return true;
      47             : 
      48         153 :         p = STARTSWITH_SET(url, "file:/", "info:", "man:");
      49          52 :         if (isempty(p))
      50           2 :                 return false;
      51             : 
      52          50 :         return ascii_is_valid(p);
      53             : }

Generated by: LCOV version 1.14