[Patch v1] check length in substring style function

Hi all, the discussion about offsets in the mixed-index branch rang a bell: I forgot to answer this post from gbbickerton: "May i suggest that a test is made to check that the string is long enough before applying this filter otherwise an exception occurs .It would be unsafe to use this filter in any style without such a test. " Attached is a small patch that implements these plausibility checks. @gbbickerton: I noticed that you use substring:1:14 which removes the 1st character as counting starts with 0. If nobody complains I'll commit this on thursday. Gerd

Hi Gerd
I forgot to answer this post from gbbickerton: "May i suggest that a test is made to check that the string is long enough before applying this filter otherwise an exception occurs .It would be unsafe to use this filter in any style without such a test. "
Well remembered, thanks. It could also do with some tests, I've attached some. I would like to use SyntaxException instead of ExitException for all cases where an error can be detected at compile time in a style file. I realise that ExitException was already used in that class. PartFilter is the only other example I can see where it does not use SyntaxException. ..Steve

Hi Steve, right. I just added a few tests. Feel free to change the patch and commit it now. Gerd Date: Tue, 16 Dec 2014 09:22:05 +0000 From: steve@parabola.me.uk To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] [Patch v1] check length in substring style function Hi Gerd
I forgot to answer this post from gbbickerton: "May i suggest that a test is made to check that the string is long enough before applying this filter otherwise an exception occurs .It would be unsafe to use this filter in any style without such a test. "
Well remembered, thanks. It could also do with some tests, I've attached some. I would like to use SyntaxException instead of ExitException for all cases where an error can be detected at compile time in a style file. I realise that ExitException was already used in that class. PartFilter is the only other example I can see where it does not use SyntaxException. ..Steve _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi all, attached is 2nd version of the patch. Steves test showed an error in my 1st patch. I've also added tests for the part function. I noticed that it is currently not possible to use ":" as a separator in the part style function. Seems not to be needed? Gerd Date: Tue, 16 Dec 2014 09:22:05 +0000 From: steve@parabola.me.uk To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] [Patch v1] check length in substring style function Hi Gerd
I forgot to answer this post from gbbickerton: "May i suggest that a test is made to check that the string is long enough before applying this filter otherwise an exception occurs .It would be unsafe to use this filter in any style without such a test. "
Well remembered, thanks. It could also do with some tests, I've attached some. I would like to use SyntaxException instead of ExitException for all cases where an error can be detected at compile time in a style file. I realise that ExitException was already used in that class. PartFilter is the only other example I can see where it does not use SyntaxException. ..Steve _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
participants (2)
-
Gerd Petermann
-
Steve Ratcliffe