]> gitweb.ps.run Git - ps-cgit/blobdiff - html.c
Restrict deep nesting of configfiles
[ps-cgit] / html.c
diff --git a/html.c b/html.c
index 957b3268be1a49a5a1d336d3412a4e71d4ca5959..175b4b687efb75d443b847738775a1de92e97cf6 100644 (file)
--- a/html.c
+++ b/html.c
@@ -45,7 +45,7 @@ void htmlf(const char *format, ...)
 void html_txt(char *txt)
 {
        char *t = txt;
-       while(*t){
+       while(t && *t){
                int c = *t;
                if (c=='<' || c=='>' || c=='&') {
                        *t = '\0';
@@ -68,7 +68,7 @@ void html_txt(char *txt)
 void html_ntxt(int len, char *txt)
 {
        char *t = txt;
-       while(*t && len--){
+       while(t && *t && len--){
                int c = *t;
                if (c=='<' || c=='>' || c=='&') {
                        *t = '\0';
@@ -97,7 +97,7 @@ void html_ntxt(int len, char *txt)
 void html_attr(char *txt)
 {
        char *t = txt;
-       while(*t){
+       while(t && *t){
                int c = *t;
                if (c=='<' || c=='>' || c=='\'') {
                        *t = '\0';
@@ -117,6 +117,15 @@ void html_attr(char *txt)
                html(txt);
 }
 
+void html_hidden(char *name, char *value)
+{
+       html("<input type='hidden' name='");
+       html_attr(name);
+       html("' value='");
+       html_attr(value);
+       html("'/>");
+}
+
 void html_link_open(char *url, char *title, char *class)
 {
        html("<a href='");
@@ -149,10 +158,11 @@ void html_filemode(unsigned short mode)
                html("d");
        else if (S_ISLNK(mode))
                html("l");
+       else if (S_ISDIRLNK(mode))
+               html("m");
        else
                html("-");
        html_fileperm(mode >> 6);
        html_fileperm(mode >> 3);
        html_fileperm(mode);
 }
-