mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-23 16:59:54 +08:00
1. The code to parse a constraint
was losing the initial double quote for a quoted string. 2. The code in ncuri.c was not properly handling occurrences of e.g. %xx
This commit is contained in:
parent
ce290d3459
commit
228e8439d2
@ -1,6 +1,8 @@
|
||||
/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
|
||||
See the COPYRIGHT file for more information. */
|
||||
|
||||
#define URLDECODE
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -11,6 +13,7 @@
|
||||
|
||||
#include "nclist.h"
|
||||
#include "ncbytes.h"
|
||||
#include "ncuri.h"
|
||||
#include "dceconstraints.h"
|
||||
#include "dceparselex.h"
|
||||
|
||||
@ -48,6 +51,7 @@ dcelex(YYSTYPE* lvalp, DCEparsestate* state)
|
||||
if(c <= ' ' || c >= '\177') {p++; continue;}
|
||||
if(c == '"') {
|
||||
int more = 1;
|
||||
ceaddyytext(lexstate,c);
|
||||
/* We have a SCAN_STRINGCONST */
|
||||
while(more && (c=*(++p))) {
|
||||
switch (c) {
|
||||
@ -190,7 +194,11 @@ dcelexinit(char* input, DCElexstate** lexstatep)
|
||||
if(lexstatep) *lexstatep = lexstate;
|
||||
if(lexstate == NULL) return;
|
||||
memset((void*)lexstate,0,sizeof(DCElexstate));
|
||||
#ifdef URLDECODE
|
||||
lexstate->input = ncuridecode(input);
|
||||
#else
|
||||
lexstate->input = strdup(input);
|
||||
#endif
|
||||
lexstate->next = lexstate->input;
|
||||
lexstate->yytext = ncbytesnew();
|
||||
lexstate->reclaim = nclistnew();
|
||||
|
@ -11,7 +11,8 @@ PROG="$TOP/ncdump/ncdump"
|
||||
P=`pwd`
|
||||
|
||||
F="http://coastwatch.pfeg.noaa.gov/erddap/tabledap/erdCinpKfmT"
|
||||
CON="temperature&longitude>=-120.&longitude<=-118.4&latitude>=33&latitude<=34&time>=2007-01-01&time<=2007-02-01"
|
||||
CON='station&station="Anacapa_Landing_Cove"'
|
||||
#CON="station,longitude,latitude,altitude,time,temperature&station=%22Anacapa_Landing_Cove%22&time>=2007-01-01&time<=2007-06-01"
|
||||
|
||||
PARMS="log"
|
||||
#PARMS="${PARMS}&netcdf3"
|
||||
@ -38,9 +39,10 @@ if test "x$PROG" = x ; then
|
||||
PROG="../ncdump/ncdump"
|
||||
fi
|
||||
|
||||
if test "x$PARMS" != "x" ; then PARMS="\#$PARMS"; fi
|
||||
U="$F"
|
||||
if test "x$CON" != "x" ; then U="$U?$CON"; fi
|
||||
UALL="$U\#${PARMS}"
|
||||
UALL="$U${PARMS}"
|
||||
#ARGS="-h $ARGS"
|
||||
#ARGS="-w $ARGS"
|
||||
#ARGS="-c $ARGS"
|
||||
|
@ -800,7 +800,6 @@ ncuridecodeonly(char* s, char* only)
|
||||
unsigned int c;
|
||||
|
||||
if (s == NULL) return NULL;
|
||||
if(only == NULL) only = "";
|
||||
|
||||
slen = strlen(s);
|
||||
decoded = (char*)malloc(slen+1); /* Should be max we need */
|
||||
@ -808,7 +807,7 @@ ncuridecodeonly(char* s, char* only)
|
||||
outptr = decoded;
|
||||
inptr = s;
|
||||
while((c = *inptr++)) {
|
||||
if(c == '+' && strchr(only,'+') != NULL)
|
||||
if(c == '+' && only != NULL && strchr(only,'+') != NULL)
|
||||
*outptr++ = ' ';
|
||||
else if(c == '%') {
|
||||
/* try to pull two hex more characters */
|
||||
@ -817,7 +816,7 @@ ncuridecodeonly(char* s, char* only)
|
||||
&& strchr(hexchars,inptr[1]) != NULL) {
|
||||
/* test conversion */
|
||||
int xc = (fromHex(inptr[0]) << 4) | (fromHex(inptr[1]));
|
||||
if(strchr(only,xc) != NULL) {
|
||||
if(only == NULL || strchr(only,xc) != NULL) {
|
||||
inptr += 2; /* decode it */
|
||||
c = xc;
|
||||
}
|
||||
|
@ -800,7 +800,6 @@ ocuridecodeonly(char* s, char* only)
|
||||
unsigned int c;
|
||||
|
||||
if (s == NULL) return NULL;
|
||||
if(only == NULL) only = "";
|
||||
|
||||
slen = strlen(s);
|
||||
decoded = (char*)malloc(slen+1); /* Should be max we need */
|
||||
@ -808,7 +807,7 @@ ocuridecodeonly(char* s, char* only)
|
||||
outptr = decoded;
|
||||
inptr = s;
|
||||
while((c = *inptr++)) {
|
||||
if(c == '+' && strchr(only,'+') != NULL)
|
||||
if(c == '+' && only != NULL && strchr(only,'+') != NULL)
|
||||
*outptr++ = ' ';
|
||||
else if(c == '%') {
|
||||
/* try to pull two hex more characters */
|
||||
@ -817,7 +816,7 @@ ocuridecodeonly(char* s, char* only)
|
||||
&& strchr(hexchars,inptr[1]) != NULL) {
|
||||
/* test conversion */
|
||||
int xc = (fromHex(inptr[0]) << 4) | (fromHex(inptr[1]));
|
||||
if(strchr(only,xc) != NULL) {
|
||||
if(only == NULL || strchr(only,xc) != NULL) {
|
||||
inptr += 2; /* decode it */
|
||||
c = xc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user