Code

CData: Fixed handling of whitespace + garbage detection at end of input.
authorSebastian Harl <sh@tokkee.org>
Tue, 30 Oct 2012 06:41:20 +0000 (07:41 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 30 Oct 2012 06:41:20 +0000 (07:41 +0100)
WTF happened there?!? ;-)

src/cdata.c

index 7ee14e643b9d8081997073e4188b2fca79c58c00..021ba1a9cafce6f4943c07d50d821b377d83ffd9 100644 (file)
@@ -160,9 +160,13 @@ cdata_in(PG_FUNCTION_ARGS)
                                ));
 
        while ((*endptr != '\0') && isspace((int)*endptr))
+               ++endptr;
+
+       if (*endptr != '\0')
                ereport(ERROR, (
                                        errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
-                                       errmsg("invalid input syntax for cdata: \"%s\"", orig)
+                                       errmsg("invalid input syntax for cdata: \"%s\"", orig),
+                                       errhint("garbage found after number: \"%s\"", endptr)
                                ));
 
        if (typmod > 0)