]> git.cameronkatri.com Git - cgit.git/blobdiff - html.c
Fix doc-related glitches in Makefile and .gitignore
[cgit.git] / html.c
diff --git a/html.c b/html.c
index 83fc7a9b7646a2dc96f87f277460c8c0857249ec..66ba65dcf6245d6e7d78ccd3d8ac1f57376fb7d8 100644 (file)
--- a/html.c
+++ b/html.c
@@ -56,9 +56,9 @@ void htmlf(const char *format, ...)
        html(buf);
 }
 
-void html_status(int code, int more_headers)
+void html_status(int code, const char *msg, int more_headers)
 {
-       htmlf("Status: %d\n", code);
+       htmlf("Status: %d %s\n", code, msg);
        if (!more_headers)
                html("\n");
 }
@@ -112,14 +112,48 @@ void html_attr(char *txt)
        char *t = txt;
        while(t && *t){
                int c = *t;
-               if (c=='<' || c=='>' || c=='\'') {
+               if (c=='<' || c=='>' || c=='\'' || c=='\"') {
                        write(htmlfd, txt, t - txt);
                        if (c=='>')
                                html("&gt;");
                        else if (c=='<')
                                html("&lt;");
                        else if (c=='\'')
-                               html("&quote;");
+                               html("&#x27;");
+                       else if (c=='"')
+                               html("&quot;");
+                       txt = t+1;
+               }
+               t++;
+       }
+       if (t!=txt)
+               html(txt);
+}
+
+void html_url_path(char *txt)
+{
+       char *t = txt;
+       while(t && *t){
+               int c = *t;
+               if (c=='"' || c=='#' || c=='\'' || c=='?') {
+                       write(htmlfd, txt, t - txt);
+                       write(htmlfd, fmt("%%%2x", c), 3);
+                       txt = t+1;
+               }
+               t++;
+       }
+       if (t!=txt)
+               html(txt);
+}
+
+void html_url_arg(char *txt)
+{
+       char *t = txt;
+       while(t && *t){
+               int c = *t;
+               if (c=='"' || c=='#' || c=='%' || c=='&' || c=='\'' || c=='+' || c=='?') {
+                       write(htmlfd, txt, t - txt);
+                       write(htmlfd, fmt("%%%2x", c), 3);
                        txt = t+1;
                }
                t++;