googleworkspace / googleworkspace/apps-script-samples

isAlnum function is incorrect in mailmerge example: check only latin symbols

Open
#185 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. Run example with column name, said in Russian or Korean language.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.