diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-01-05 16:49:21 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-01-05 16:49:56 +0100 |
| commit | 93d8fccd51a704c4accd535743a963ad0ca5a274 (patch) | |
| tree | 5b4868ad6804afdc8f7a616c04c096bbf61bd0f3 | |
| parent | 367771f4bae20698c0740c7dd469a5b10bc28673 (diff) | |
| download | PROJ-93d8fccd51a704c4accd535743a963ad0ca5a274.tar.gz PROJ-93d8fccd51a704c4accd535743a963ad0ca5a274.zip | |
createFromUserInput(): accept leading white space (fixes #2498)
| -rw-r--r-- | src/iso19111/io.cpp | 6 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index dc51c5d9..c0844608 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -6132,6 +6132,12 @@ static BaseObjectNNPtr createFromUserInput(const std::string &text, const DatabaseContextPtr &dbContext, bool usePROJ4InitRules, PJ_CONTEXT *ctx) { + std::size_t idxFirstCharNotSpace = text.find_first_not_of(" \t\r\n"); + if (idxFirstCharNotSpace > 0 && idxFirstCharNotSpace != std::string::npos) { + return createFromUserInput(text.substr(idxFirstCharNotSpace), dbContext, + usePROJ4InitRules, ctx); + } + if (!text.empty() && text[0] == '{') { json j; try { diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 4e903473..dfa75cd9 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -10543,7 +10543,7 @@ TEST(io, createFromUserInput) { "MGI (Ferro) to MGI (1) + MGI to WGS 84 (3)"); } EXPECT_NO_THROW(createFromUserInput( - "GEOGCRS[\"WGS 84\",\n" + " \n\t\rGEOGCRS[\"WGS 84\",\n" " DATUM[\"World Geodetic System 1984\",\n" " ELLIPSOID[\"WGS 84\",6378137,298.257223563]],\n" " CS[ellipsoidal,3],\n" |
