koopjs / koop

Transform, query, and download geospatial data on the web.
http://koopjs.github.io
Other
651 stars 125 forks source link

Invalid regular expression when field contains plus sign anywhere in its value #969

Closed AndrewAdamson closed 1 month ago

AndrewAdamson commented 2 months ago

As the title states. If a field contains a plus sign koop will return a regular expression error:

{ "error": { "code": 500, "message": "Invalid regular expression: /^(?!0{4}+0{2}+0{2})((?=[0-9]{4}+(((0[^2])|1[0-2])|02(?=+(([0-1][0-9])|2[0-8])))+[0-9]{2})|(?=((([13579][26])|([2468][048])|(0[48]))0{2})|([0-9]{2}((((0|[2468])[48])|[2468][048])|([13579][26])))+02+29))([0-9]{4})+(?!((0[469])|11)+31)((0[1,3-9]|1[0-2])|(02(?!+3)))+(0[1-9]|[1-2][0-9]|3[0-1])$/: Nothing to repeat", "details": [ "Invalid regular expression: /^(?!0{4}+0{2}+0{2})((?=[0-9]{4}+(((0[^2])|1[0-2])|02(?=+(([0-1][0-9])|2[0-8])))+[0-9]{2})|(?=((([13579][26])|([2468][048])|(0[48]))0{2})|([0-9]{2}((((0|[2468])[48])|[2468][048])|([13579][26])))+02+29))([0-9]{4})+(?!((0[469])|11)+31)((0[1,3-9]|1[0-2])|(02(?!+3)))+(0[1-9]|[1-2][0-9]|3[0-1])$/: Nothing to repeat" ] } }

I can confirm by removing a field that may contain a plus sign anywhere in the value: "ANNOYINGFIELD": "123+10".

This is related to this issue and iso-datestring-validator. The fix in koop is to check the first character for a problem string in date-type-utils.js. Whereas this issue is a plus sign anywhere in the string which can conflict to other date formats with timezone info.

I've been able to handle this on my end by modifying the isDate function in data-type-utils,js with a includes check specific to '+' - its specific to my data so not very helpful in a global sense.

rgwozdz commented 2 months ago

Thanks @AndrewAdamson. Will try to patch this soon.

rgwozdz commented 1 month ago

Fixed in https://github.com/koopjs/koop/pull/1008