Changeset 745


Ignore:
Timestamp:
Dec 12, 2015, 5:39:48 PM (8 years ago)
Author:
djay
Message:

Fix issue when XML request contains empty nodes for inputs

Location:
trunk/zoo-project/zoo-kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/Makefile.in

    r735 r745  
    9494
    9595libzoo_service.${EXT}: version.h service_internal.o service.o sqlapi.o
    96         gcc -shared  ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS}  service_internal.o service.o sqlapi.o -lfcgi ${GDAL_LIBS}
     96        gcc -shared  ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS}  service_internal.o service.o sqlapi.o ${FCGI_LDFLAGS} ${GDAL_LIBS}
    9797
    9898zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o request_parser.o response_print.o server_internal.o caching.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE}
  • trunk/zoo-project/zoo-kernel/request_parser.c

    r725 r745  
    483483
    484484/**
     485 * Create a "missingIdentifier" maps in case it is NULL.
     486 *
     487 * @param main_conf the conf maps containing the main.cfg settings
     488 * @param mymaps the maps to update
     489 * @return 0 on success, 4 on failure
     490 */
     491int defineMissingIdentifier(maps** main_conf,maps** mymaps){
     492  if (*mymaps == NULL){
     493    *mymaps = (maps *) malloc (MAPS_SIZE);
     494    if (*mymaps == NULL){
     495      return errorException (*main_conf,
     496                             _("Unable to allocate memory"),
     497                             "InternalError", NULL);
     498    }
     499    (*mymaps)->name = zStrdup ("missingIndetifier");
     500    (*mymaps)->content = NULL;
     501    (*mymaps)->next = NULL;
     502  }
     503  return 0;
     504}
     505
     506/**
    485507 * Parse inputs from XML nodes and store them in a maps.
    486508 *
     
    528550                  xmlChar *val =
    529551                    xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
    530                   if (tmpmaps == NULL)
     552                  if (tmpmaps == NULL && val!=NULL)
    531553                    {
    532554                      tmpmaps = (maps *) malloc (MAPS_SIZE);
     
    541563                      tmpmaps->content = NULL;
    542564                      tmpmaps->next = NULL;
     565                      xmlFree (val);
    543566                    }
    544                   xmlFree (val);
    545567                }
    546568              // Title, Asbtract
     
    553575                  xmlChar *val =
    554576                    xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
    555                   if (tmpmaps == NULL)
    556                     {
    557                       tmpmaps = (maps *) malloc (MAPS_SIZE);
    558                       if (tmpmaps == NULL)
    559                         {
    560                           return errorException (*main_conf,
    561                                                  _
    562                                                  ("Unable to allocate memory"),
    563                                                  "InternalError", NULL);
    564                         }
    565                       tmpmaps->name = zStrdup ("missingIndetifier");
     577                  defineMissingIdentifier(main_conf,&tmpmaps);
     578                  if(val!=NULL){
     579                    if (tmpmaps->content != NULL)
     580                      addToMap (tmpmaps->content,
     581                                (char *) cur2->name, (char *) val);
     582                    else
    566583                      tmpmaps->content =
    567584                        createMap ((char *) cur2->name, (char *) val);
    568                       tmpmaps->next = NULL;
    569                     }
    570                   else
    571                     {
    572                       if (tmpmaps->content != NULL)
    573                         addToMap (tmpmaps->content,
    574                                   (char *) cur2->name, (char *) val);
    575                       else
    576                         tmpmaps->content =
    577                           createMap ((char *) cur2->name, (char *) val);
    578                     }
    579                   xmlFree (val);
     585                    xmlFree (val);
     586                  }
    580587                }
    581588              // InputDataFormChoice (Reference or Data ?)
    582589              if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
    583590                {
     591                  defineMissingIdentifier(main_conf,&tmpmaps);
    584592                  // Get every attribute from a Reference node
    585593                  // mimeType, encoding, schema, href, method
     
    721729
    722730                                      sprintf (tmp, "%s", (char*) btmps);
    723                                          
    724                                       xmlFreeDoc (bdoc);
     731
     732                                      //xmlFreeDoc (bdoc);
    725733                                         
    726734                                      map *btmp =
     
    815823              else if (xmlStrcasecmp (cur2->name, BAD_CAST "Data") == 0)
    816824                {
     825                  defineMissingIdentifier(main_conf,&tmpmaps);
    817826                  xmlNodePtr cur4 = cur2->children;
    818827                  if(vid==1){
     
    946955                                     && cur5->type != XML_CDATA_SECTION_NODE)
    947956                                cur5 = cur5->next;
     957                              fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     958                              fflush(stderr);
    948959                              if (cur5 != NULL
    949960                                  && cur5->type != XML_CDATA_SECTION_NODE)
     
    953964                                                             &buffersize,
    954965                                                             "utf-8", 0);
    955                                   addIntToMap (tmpmaps->content, "size",
    956                                                buffersize);
    957                                   xmlFreeDoc (doc1);
    958966                                }
    959967                              else
     
    961969                                  if (cur5 != NULL
    962970                                      && cur5->type == XML_CDATA_SECTION_NODE){
    963                                     xmlDocPtr doc2 = xmlParseMemory((const char*)cur5->content,xmlStrlen(cur5->content));
    964                                     xmlDocSetRootElement (doc1,xmlDocGetRootElement(doc2));
    965                                     xmlDocDumpFormatMemoryEnc (doc1, &mv,
     971                                    xmlDocPtr doc2 = xmlReadMemory((const char*)cur5->content,xmlStrlen(cur5->content),
     972                                                                   "input_content.xml", NULL, XML_PARSE_RECOVER);
     973                                    xmlDocDumpFormatMemoryEnc (doc2, &mv,
    966974                                                               &buffersize,
    967975                                                               "utf-8", 0);
    968                                     addIntToMap(tmpmaps->content, "size",buffersize);
    969976                                    xmlFreeDoc (doc2);
    970                                     xmlFreeDoc (doc1);
    971977                                  }
    972978                                }
     979                              addIntToMap (tmpmaps->content, "size",
     980                                           buffersize);
     981                              xmlFreeDoc (doc1);
    973982                            }else{
    974983                            xmlNodePtr cur5 = cur4->children;
     
    10081017            }
    10091018          {
     1019            map* test=getMap(tmpmaps->content,"value");
     1020            if(test==NULL)
     1021              addToMap(tmpmaps->content,"value","");
    10101022            maps *testPresence =
    10111023              getMaps (*request_output, tmpmaps->name);
     
    13241336
    13251337  xmlInitParser ();
    1326   xmlDocPtr doc = xmlParseMemory (post, cgiContentLength);
     1338  xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER);
    13271339
    13281340  /**
  • trunk/zoo-project/zoo-kernel/service_yaml.c

    r580 r745  
    4646 */
    4747int getServiceFromYAML(maps* conf, char* file,service** service,char *name){
    48   FILE *fh = fopen("test.yml", "r");
     48  FILE *fh;
    4949  if(current_content!=NULL){
    5050    freeMap(&current_content);
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r718 r745  
    216216      addToMap(tmpMap,"xrequest",t1->value);
    217217      xmlInitParser();
    218       xmlDocPtr doc = xmlParseMemory(t1->value,cgiContentLength);
     218      xmlDocPtr doc = xmlReadMemory(t1->value, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER);
    219219      {
    220220        xmlXPathObjectPtr reqptr=extractFromDoc(doc,"/*[local-name()='Envelope']/*[local-name()='Body']/*");
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r738 r745  
    961961      setenv ("LC_ALL", tmp, 1);
    962962#else
    963           char tmp1[13];
     963      char tmp1[13];
    964964      sprintf (tmp1, "LC_ALL=%s", tmp);
    965965      putenv (tmp1);
     
    973973      setenv ("LC_ALL", "en_US", 1);
    974974#else
    975           char tmp1[13];
     975      char tmp1[13];
    976976      sprintf (tmp1, "LC_ALL=en_US");
    977977      putenv (tmp1);
     
    979979      setMapInMaps (m, "main", "language", "en-US");
    980980    }
    981   setlocale (LC_NUMERIC, "en_US");
     981  setlocale (LC_NUMERIC, "C");
     982#ifndef WIN32
     983  setenv ("LC_NUMERIC", "C", 1);
     984#else
     985  char tmp1[17];
     986  sprintf (tmp1, "LC_NUMERIC=C");
     987  putenv (tmp1);
     988#endif
    982989  bind_textdomain_codeset ("zoo-kernel", "UTF-8");
    983990  textdomain ("zoo-kernel");
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png