]> code.citadel.org Git - citadel.git/blobdiff - webcit/paramhandling.c
* bust the other places still accessing token values directly:
[citadel.git] / webcit / paramhandling.c
index 2a9848e36adec1e6e59f6aee8c86f12a3fe9f6a9..c656734410b6a8a12683b6351891c3fe62cfdfa1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: paramhandling.c 6808 2008-12-11 00:00:36Z dothebart $
+ * $Id$
  *
  * parse urlparts and post data
  */
@@ -320,8 +320,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp,
        if ( (length > 0) && (!IsEmptyStr(cbtype)) ) {
                WCC->upload = NewStrBufPlain(content, length);
                WCC->upload_length = length;
-               safestrncpy(WCC->upload_filename, filename,
-                           sizeof(WC->upload_filename));
+               WCC->upload_filename = NewStrBufPlain(filename, -1);
                safestrncpy(WCC->upload_content_type, cbtype,
                            sizeof(WC->upload_content_type));
                
@@ -353,11 +352,21 @@ int ConditionalBstr(StrBuf *Target, WCTemplputParams *TP)
        if(TP->Tokens->nParameters == 3)
                return HaveBstr(TKEY(2));
        else {
-               if (TP->Tokens->Params[3]->Type == TYPE_LONG)
-                       return LBstr(TKEY(2)) == TP->Tokens->Params[3]->lvalue;
-               else 
-                       return strcmp(Bstr(TKEY(2)),
-                                     TP->Tokens->Params[3]->Start) == 0;
+               if (IS_NUMBER(TP->Tokens->Params[3]->Type))
+               {
+                       return LBstr(TKEY(2)) == 
+                               GetTemplateTokenNumber(Target, 
+                                                      TP, 
+                                                      3, 
+                                                      0);
+               }
+               else {
+                       const char *pch;
+                       long len;
+
+                       GetTemplateTokenString (Target, TP, 3, &pch, &len);
+                       return strcmp(Bstr(TKEY(2)), pch) == 0;
+               }
        }
 }
 
@@ -395,11 +404,14 @@ void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
        wcsession *WCC = WC;
        
        if (WCC != NULL) {
-               if (TP->Tokens->Params[0]->lvalue == 0) {
+               long n;
+
+               n = GetTemplateTokenNumber(Target, TP, 0, 0);
+               if (n == 0) {
                        if (WCC->Hdr->HR.Handler != NULL)
                                UrlBuf = Name = WCC->Hdr->HR.Handler->Name;
                }
-               else if (TP->Tokens->Params[0]->lvalue == 1) {
+               else if (n == 1) {
                        UrlBuf = NewStrBuf();
                        StrBufExtract_token(UrlBuf, WCC->Hdr->HR.ReqLine, 0, '/');
                }
@@ -441,4 +453,5 @@ SessionDetachModule_PARAMHANDLING
 (wcsession *sess)
 {
        DeleteHash(&sess->Hdr->urlstrings);
+       FreeStrBuf(&sess->upload_filename);
 }