Initial commit of numbers to words converter in Dutch#218
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces an Espanso package to convert numeric currency amounts into fully written-out Dutch text (based on zegge.nu).
Changes:
- Added package metadata via
_manifest.yml. - Added Espanso match configuration and an embedded Python converter script in
package.yml. - Added usage and installation documentation in
README.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/number-to-words-nl/0.1.0/README.md | Documents the package purpose, install command, and basic usage. |
| packages/number-to-words-nl/0.1.0/package.yml | Defines the :nr trigger, input form, and Python-based conversion logic. |
| packages/number-to-words-nl/0.1.0/_manifest.yml | Adds Espanso Hub manifest metadata (name/version/tags). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') | ||
|
|
||
| getal = '{{form1.getal}}' | ||
|
|
There was a problem hiding this comment.
User-provided form input is interpolated directly into the Python source (getal = '{{form1.getal}}'). If the input contains a single quote/newline it can break the string literal and inject arbitrary Python code. Pass the value as a separate argv argument (or encode via JSON) and read it from sys.argv instead of templating it into the script.
There was a problem hiding this comment.
I'm not overly concerned about this - all data entered is going to come locally from the user. If they want to try and inject arbitrary Python code that's up to them.
There was a problem hiding this comment.
A fun package to convert numbers to Dutch written currency text. Uses an inline Python script to process the data entered via a form. The script appears benign, with no malicious code.
I've let Copilot do its stuff and it raises a number of issues, some of which need addressing and others which can be ignored - see my notes.
There are some minor inconsistencies in use, but these may be intentional:
12.34→twaalf euro en vierendertig eurocent
12,34→twaalf euro en vierendertig eurocent
12.345→twaalfduizend driehonderdvijfenveertig euro
12,345→twaalfduizend driehonderdvijfenveertig euro
It doesn't distinguish between periods . and commas ,, which I suppose allows for Dutch and English number formats to be used.
| sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') | ||
|
|
||
| getal = '{{form1.getal}}' | ||
|
|
There was a problem hiding this comment.
I'm not overly concerned about this - all data entered is going to come locally from the user. If they want to try and inject arbitrary Python code that's up to them.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed installation instructions from README.
|
Applied the suggested changes where necessary, The periods and commas was indeed intentional to allow multiple input formats. |
smeech
left a comment
There was a problem hiding this comment.
Thank you. That looks better.
I'll re-run Copilot and the automated checks and merge if all is well.
| - 150 becomes honderdvijftig euro | ||
| - 1 009 123,50 becomes een miljoen negenduizend honderddrieëntwintig euro en vijftig eurocent |
| # Zoek het laatste scheidingsteken (. of ,) | ||
| laatste_punt = getal_str.rfind('.') | ||
| laatste_komma = getal_str.rfind(',') | ||
| laatste_scheiding = max(laatste_punt, laatste_komma) | ||
|
|
||
| if laatste_scheiding > 0: | ||
| # Controleer of er 1 of 2 cijfers na het laatste scheidingsteken staan | ||
| na_scheiding = getal_str[laatste_scheiding + 1:] | ||
| if len(na_scheiding) <= 2 and na_scheiding.isdigit(): | ||
| # Dit is het decimaalteken | ||
| hoofdgetal = getal_str[:laatste_scheiding].replace('.', '').replace(',', '') | ||
| decimalen = (na_scheiding + '00')[:2] | ||
| else: | ||
| # Geen decimalen, alles is hoofdgetal | ||
| hoofdgetal = getal_str.replace('.', '').replace(',', '') | ||
| decimalen = '' | ||
| else: | ||
| hoofdgetal = getal_str | ||
| decimalen = '' |
|
Merged - it'll take a few hours to appear on the Hub website. Thank you. |
Based on the website https://www.zegge.nu where you can convert numbers to full written-out words
number.to.words.converter.mp4