googleworkspace / googleworkspace/apps-script-samples
isAlnum function is incorrect in mailmerge example: check only latin symbols
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.2k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
Expected Behavior
Provided sample mail_merge works as described. Really it works only for headers with latin symbols (e.g. English).
Sample URL: https://sites.google.com/site/scriptsexamples/custom-methods/create-text-from-template#TOC-Documentation
Description: The cause is isAlnum function. That is naively implemented as:
function isAlnum(char) {
return char >= 'A' && char <= 'Z' ||
char >= 'a' && char <= 'z' ||
isDigit(char);
}
But Unicode standard describe much more "Alpha" symbols in different categories.
So really that function should be implemented like:
function isAlnum(char) {
return !! char.match(/[\p{Number}\p{Letter}]/u)
}
and also function isDigit may be dropped (that also potentially has similar problems)
Actual Behavior
Headers on said in Russian or Korean language just ignored and values does not substituted in template.
Steps to Reproduce the Problem
- Run example with column name, said in Russian or Korean language.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open gmail/mailmerge/mailmerge.gs and inspect the isAlnum function referenced in the issue. Run the mailmerge example with Russian or Korean column headers, then verify that the updated character check substitutes those header values while preserving existing behavior for Latin headers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100