[BACK]Return to cgi.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/cgi.c between version 1.151 and 1.157

version 1.151, 2017/03/15 13:49:50 version 1.157, 2018/05/18 14:23:00
Line 140  html_putchar(char c)
Line 140  html_putchar(char c)
 {  {
   
         switch (c) {          switch (c) {
         case ('"'):          case '"':
                 printf(""");                  printf(""");
                 break;                  break;
         case ('&'):          case '&':
                 printf("&");                  printf("&");
                 break;                  break;
         case ('>'):          case '>':
                 printf(">");                  printf(">");
                 break;                  break;
         case ('<'):          case '<':
                 printf("&lt;");                  printf("&lt;");
                 break;                  break;
         default:          default:
Line 356  resp_begin_html(int code, const char *msg, const char 
Line 356  resp_begin_html(int code, const char *msg, const char 
                "<html>\n"                 "<html>\n"
                "<head>\n"                 "<head>\n"
                "  <meta charset=\"UTF-8\"/>\n"                 "  <meta charset=\"UTF-8\"/>\n"
                  "  <meta name=\"viewport\""
                         " content=\"width=device-width, initial-scale=1.0\">\n"
                "  <link rel=\"stylesheet\" href=\"%s/mandoc.css\""                 "  <link rel=\"stylesheet\" href=\"%s/mandoc.css\""
                " type=\"text/css\" media=\"all\">\n"                 " type=\"text/css\" media=\"all\">\n"
                "  <title>",                 "  <title>",
Line 554  pg_error_internal(void)
Line 556  pg_error_internal(void)
 static void  static void
 pg_redirect(const struct req *req, const char *name)  pg_redirect(const struct req *req, const char *name)
 {  {
         printf("Status: 303 See Other\r\n");          printf("Status: 303 See Other\r\n"
         printf("Location: http://%s/", HTTP_HOST);              "Location: /");
         if (*scriptname != '\0')          if (*scriptname != '\0')
                 printf("%s/", scriptname);                  printf("%s/", scriptname);
         if (strcmp(req->q.manpath, req->p[0]))          if (strcmp(req->q.manpath, req->p[0]))
Line 591  pg_searchres(const struct req *req, struct manpage *r,
Line 593  pg_searchres(const struct req *req, struct manpage *r,
                  * If we have just one result, then jump there now                   * If we have just one result, then jump there now
                  * without any delay.                   * without any delay.
                  */                   */
                 printf("Status: 303 See Other\r\n");                  printf("Status: 303 See Other\r\n"
                 printf("Location: http://%s/%s%s%s/%s",                      "Location: /");
                     HTTP_HOST, scriptname,                  if (*scriptname != '\0')
                     *scriptname == '\0' ? "" : "/",                          printf("%s/", scriptname);
                     req->q.manpath, r[0].file);                  if (strcmp(req->q.manpath, req->p[0]))
                 printf("\r\n"                          printf("%s/", req->q.manpath);
                      "Content-Type: text/html; charset=utf-8\r\n"                  printf("%s\r\n"
                      "\r\n");                      "Content-Type: text/html; charset=utf-8\r\n\r\n",
                       r[0].file);
                 return;                  return;
         }          }
   
Line 831  resp_format(const struct req *req, const char *file)
Line 834  resp_format(const struct req *req, const char *file)
   
         mchars_alloc();          mchars_alloc();
         mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1,          mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1,
             MANDOCLEVEL_BADARG, NULL, req->q.manpath);              MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, req->q.manpath);
         mparse_readfd(mp, fd, file);          mparse_readfd(mp, fd, file);
         close(fd);          close(fd);
   
Line 839  resp_format(const struct req *req, const char *file)
Line 842  resp_format(const struct req *req, const char *file)
         conf.fragment = 1;          conf.fragment = 1;
         conf.style = mandoc_strdup(CSS_DIR "/mandoc.css");          conf.style = mandoc_strdup(CSS_DIR "/mandoc.css");
         usepath = strcmp(req->q.manpath, req->p[0]);          usepath = strcmp(req->q.manpath, req->p[0]);
         mandoc_asprintf(&conf.man, "/%s%s%%N.%%S",          mandoc_asprintf(&conf.man, "/%s%s%s%s%%N.%%S",
               scriptname, *scriptname == '\0' ? "" : "/",
             usepath ? req->q.manpath : "", usepath ? "/" : "");              usepath ? req->q.manpath : "", usepath ? "/" : "");
   
         mparse_result(mp, &man, NULL);          mparse_result(mp, &man, NULL);
Line 1071  main(void)
Line 1075  main(void)
   
         if (*path != '\0') {          if (*path != '\0') {
                 parse_path_info(&req, path);                  parse_path_info(&req, path);
                 if (req.q.manpath == NULL || access(path, F_OK) == -1)                  if (req.q.manpath == NULL || req.q.sec == NULL ||
                       *req.q.query == '\0' || access(path, F_OK) == -1)
                         path = "";                          path = "";
         } else if ((querystring = getenv("QUERY_STRING")) != NULL)          } else if ((querystring = getenv("QUERY_STRING")) != NULL)
                 parse_query_string(&req, querystring);                  parse_query_string(&req, querystring);

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.157

CVSweb