-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: shell-daemons action: commit revision: path_from: revision_from: 2a2e655201b307c42e4a9e7339d33bf7363ad0d8: path_to: revision_to:
commit 2a2e655201b307c42e4a9e7339d33bf7363ad0d8 Author: epoch <epoch@hack.thebackupbox.net> Date: Mon Sep 20 08:17:11 2021 +0000 first-pass at getting unquoted values working too. diff --git a/auth-param.c b/auth-param.c
--- a/auth-param.c +++ b/auth-param.c @@ -21,6 +21,7 @@ int main(int argc,char *argv[]) { char *nend; char *value; char *vend; + char quoted; if(argc < 2) { printf("usage: csv derp name\n"); return 1; @@ -37,12 +38,19 @@ int main(int argc,char *argv[]) { *value=0; value++; while(*value && (*value == ' ' || *value == '\t')) value++;//skip over whitespace - if(*value != '"') return __LINE__;//malformed because missing a double-quote after the = - value++; - vend=strchr(value,'"'); - if(!vend) return __LINE__;//malformed because missing a closing double-quote - while(vend && *vend && *(vend-1)=='\\') vend=strchr(vend+1,'"'); - if(!vend) return __LINE__;//malformed because missing an unescape double-quote to close value. + //it actually might not have a " after the whitespace after the = + quoted=0; + if(*value == '"') { + quoted=1; //return __LINE__;//malformed because missing a double-quote after the = + value++;//skip the " + vend=strchr(value,'"'); + if(!vend) return __LINE__;//malformed because missing a closing double-quote + while(vend && *vend && *(vend-1)=='\\') vend=strchr(vend+1,'"'); + if(!vend) return __LINE__;//malformed because missing an unescape double-quote to close value. + } else { + vend=value; + while(*vend != ' ' && *vend != '\t' && *vend != ',' && *vend != '\0') vend++;//loop until an end condition of value. + } *vend=0; //fprintf(stderr,"'%s' = '%s'\n",name,value); if(argc == 2) { @@ -50,11 +58,12 @@ int main(int argc,char *argv[]) { } if(argc == 3) { if(!strcmp(name,argv[2])) { - printf("\"%s\"\n",value); + if(quoted) printf("\"%s\"\n",value); + else printf("%s\n",value); } } - vend++; - while(*vend && (*vend == ' ' || *vend == '\t')) vend++; + vend++;//this is to move the vend to the first character after the null vend used to be. + while(*vend && (*vend == ' ' || *vend == '\t')) vend++;//skip any whitespace ofc. if(*vend == '\0') break;//we're at the end of the string, exit. if(*vend != ',') return __LINE__;//need a comma after the closing string if not at end name=vend+1;
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 10:50:31 2024