aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/internal.cpp34
-rw-r--r--src/iso19111/io.cpp5
-rw-r--r--src/param.cpp27
3 files changed, 34 insertions, 32 deletions
diff --git a/src/internal.cpp b/src/internal.cpp
index e934069f..b7648924 100644
--- a/src/internal.cpp
+++ b/src/internal.cpp
@@ -326,6 +326,31 @@ argument string, args, and count its number of elements.
}
+static void unquote_string(char* param_str) {
+
+ size_t len = strlen(param_str);
+ // Remove leading and terminating spaces after equal sign
+ const char* equal = strstr(param_str, "=\"");
+ if( equal && equal - param_str + 1 >= 2 && param_str[len-1] == '"' ) {
+ size_t dst = equal + 1 - param_str;
+ size_t src = dst + 1;
+ for( ; param_str[src]; dst++, src++)
+ {
+ if( param_str[src] == '"' ) {
+ if( param_str[src+1] == '"' ) {
+ src++;
+ } else {
+ break;
+ }
+ }
+ param_str[dst] = param_str[src];
+ }
+ param_str[dst] = '\0';
+ }
+
+}
+
+
/*****************************************************************************/
char **pj_trim_argv (size_t argc, char *args) {
@@ -349,7 +374,6 @@ It is the duty of the caller to free this array.
if (0==argc)
return nullptr;
-
/* turn the input string into an array of strings */
char** argv = (char **) calloc (argc, sizeof (char *));
if (nullptr==argv)
@@ -359,6 +383,7 @@ It is the duty of the caller to free this array.
char* str = argv[j];
size_t nLen = strlen(str);
i += nLen + 1;
+ unquote_string(str);
}
return argv;
}
@@ -370,7 +395,11 @@ std::string pj_double_quote_string_param_if_needed(const std::string& str) {
if( str.find(' ') == std::string::npos ) {
return str;
}
- return '"' + replaceAll(str, "\"", "\"\"") + '"';
+ std::string ret;
+ ret += '"';
+ ret += replaceAll(str, "\"", "\"\"");
+ ret += '"';
+ return ret;
}
/*****************************************************************************/
@@ -383,7 +412,6 @@ Allocates, and returns, an array of char, large enough to hold a whitespace
separated copy of the args in argv. It is the duty of the caller to free this
array.
******************************************************************************/
-
try
{
std::string s;
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index f8a4672a..73712b17 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -10527,7 +10527,8 @@ PROJStringParser::createFromPROJString(const std::string &projString) {
expanded += pair.key;
if (!pair.value.empty()) {
expanded += '=';
- expanded += pair.value;
+ expanded += pj_double_quote_string_param_if_needed(
+ pair.value);
}
}
expanded += ' ';
@@ -10583,7 +10584,7 @@ PROJStringParser::createFromPROJString(const std::string &projString) {
expanded += pair.key;
if (!pair.value.empty()) {
expanded += '=';
- expanded += pair.value;
+ expanded += pj_double_quote_string_param_if_needed(pair.value);
}
}
diff --git a/src/param.cpp b/src/param.cpp
index 21afc57f..0a9a66d8 100644
--- a/src/param.cpp
+++ b/src/param.cpp
@@ -9,31 +9,6 @@
#include "proj.h"
#include "proj_internal.h"
-static void unquote_string(char* param_str) {
-
- size_t len = strlen(param_str);
- // Remove leading and terminating spaces after equal sign
- const char* equal = strstr(param_str, "=\"");
- if( equal && equal - param_str + 1 > 2 && param_str[len-1] == '"' ) {
- size_t dst = equal + 1 - param_str;
- size_t src = dst + 1;
- for( ; param_str[src]; dst++, src++)
- {
- if( param_str[src] == '"' ) {
- if( param_str[src+1] == '"' ) {
- src++;
- } else {
- break;
- }
- }
- param_str[dst] = param_str[src];
- }
- param_str[dst] = '\0';
- }
-
-}
-
-
/* create parameter list entry */
paralist *pj_mkparam(const char *str) {
paralist *newitem;
@@ -44,7 +19,6 @@ paralist *pj_mkparam(const char *str) {
if (*str == '+')
++str;
(void)strcpy(newitem->param, str);
- unquote_string(newitem->param);
}
return newitem;
}
@@ -86,7 +60,6 @@ paralist *pj_mkparam_ws (const char *str, const char **next_str) {
if (nullptr==newitem)
return nullptr;
memcpy(newitem->param, str, len);
- unquote_string(newitem->param);
newitem->used = 0;
newitem->next = nullptr;