<p>Well, the code didn't really check, if the field contains a number. In many cases that's not really an issue if the value can be implicitly converted to a number. It fails though, when people use multiple values, like in <code>layer = 4;3</code>, or put in some other non-numeric value in there.</p>
<div class="highlight highlight-source-lua"><pre><span class="pl-k">></span> <span class="pl-c1">print</span>(<span class="pl-c1">5</span><span class="pl-k">*</span><span class="pl-s"><span class="pl-pds">"</span>4<span class="pl-pds">"</span></span>)
<span class="pl-c1">20</span>
<span class="pl-k">></span> <span class="pl-c1">print</span>(<span class="pl-c1">tonumber</span>(<span class="pl-s"><span class="pl-pds">"</span>4<span class="pl-pds">"</span></span>))
<span class="pl-c1">4</span>
</pre></div>
<div class="highlight highlight-source-lua"><pre><span class="pl-k">></span> <span class="pl-c1">print</span>(<span class="pl-c1">5</span><span class="pl-k">*</span><span class="pl-s"><span class="pl-pds">"</span>4;3<span class="pl-pds">"</span></span>)
stdin:<span class="pl-c1">1</span>: attempt to perform arithmetic on a string value
stack traceback:
stdin:<span class="pl-c1">1</span>: <span class="pl-k">in</span> main chunk
[C]: <span class="pl-k">in</span> ?
<span class="pl-k">></span> <span class="pl-c1">print</span>(<span class="pl-c1">tonumber</span>(<span class="pl-s"><span class="pl-pds">"</span>4;3<span class="pl-pds">"</span></span>))
<span class="pl-c1">nil</span>
</pre></div>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/osm2pgsql/pull/845#issuecomment-398541525">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AD2-7mbl2RZanQHWbavuPBSG8xLaouCgks5t-WRugaJpZM4Te-pY">mute the thread</a>.<img src="https://github.com/notifications/beacon/AD2-7nzIS9-BSSKgwYaoXyYuBpEqGIs_ks5t-WRugaJpZM4Te-pY.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","potentialAction":{"@type":"ViewAction","target":"https://github.com/openstreetmap/osm2pgsql/pull/845#issuecomment-398541525","url":"https://github.com/openstreetmap/osm2pgsql/pull/845#issuecomment-398541525","name":"View Pull Request"},"description":"View this Pull Request on GitHub","publisher":{"@type":"Organization","name":"GitHub","url":"https://github.com"}}</script>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/osm2pgsql","title":"openstreetmap/osm2pgsql","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/osm2pgsql"}},"updates":{"snippets":[{"icon":"PERSON","message":"@mmd-osm in #845: Well, the code didn't really check, if the field contains a number. In many cases that's not really an issue if the value can be implicitly converted to a number. It fails though, when people use multiple values, like in `layer = 4;3`, or put in some other non-numeric value in there.\r\n\r\n```lua\r\n\u003e print(5*\"4\")\r\n20\r\n\u003e print(tonumber(\"4\"))\r\n4\r\n\r\n```\r\n\r\n```lua\r\n\u003e print(5*\"4;3\")\r\nstdin:1: attempt to perform arithmetic on a string value\r\nstack traceback:\r\n\tstdin:1: in main chunk\r\n\t[C]: in ?\r\n\u003e print(tonumber(\"4;3\"))\r\nnil\r\n\r\n```\r\n\r\n\r\n"}],"action":{"name":"View Pull Request","url":"https://github.com/openstreetmap/osm2pgsql/pull/845#issuecomment-398541525"}}}</script>
<script type="application/ld+json">{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [openstreetmap/osm2pgsql] Lua function errors now trigger runtime exception (#845)",
"sections": [
{
"text": "",
"activityTitle": "**mmd**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@mmd-osm",
"facts": [
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"openstreetmap/osm2pgsql\",\n\"issueId\": 845,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/openstreetmap/osm2pgsql/pull/845#issuecomment-398541525"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 326888024\n}"
}
],
"themeColor": "26292E"
}</script>