Skip to content

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

Open
@Hubbitus

Description

@Hubbitus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions