[OPEN-ILS-GENERAL] support ofr non latin scripts in Circulation

Dan Scott denials at gmail.com
Tue Feb 3 10:06:34 EST 2009


2009/2/3 Tigran Zargaryan <tigran at flib.sci.am>:
> Hello List,
> In the 'Register patron - User identification' module when typing patrons
> first name, middle, name last name in non-latin scripts (Armenian, Cyrillic,
> Arabic), these fields are remaining red, and 'View Errors' is prompting
>  '... name is invalid'.
> When changing the first letter in these fields to the Latin (keeping other
> letters in non-Latin) the system is accepting the string without any errors.
> Is this a bug?
> thanks,

Hi Tigran:

It's a bug from the perspective of most libraries outside of the state
of Georgia, but a feature for the state of Georgia. The original
design goal was to use prevent people from accidentally entering
information such as street numbers into the wrong fields, and to
ensure that the input data was valid for the state of Georgia.  To
that end, a set of regular expressions is used to check that the
content of a given field matches the corresponding expected input
pattern.

However, as Evergreen has grown those default regular expressions have
remained in place and we have not yet replaced those input field
validation algorithms with a more flexible approach. For our own use
of Evergreen in an academic context, we have students who live in many
different countries, so validating states or provinces or postal codes
doesn't make much sense for us. Also, JavaScript as of EcmaScript 3
defines "\w" to only match a-zA-Z0-9_ - it does not match Unicode
character classes. (I would guess that patrons with names containing
non-Latin characters at public libraries in the state of Georgia just
use Romanized versions of their name, avoiding this problem.)

All that to say: if you open
Open-ILS/xul/staff_client/server/patron/ue_config.js in a text editor,
you will find the regular expressions defined as:

const numRegex		= /^\d+$/;
const wordRegex	= /^[\w-]+$/;
const unameRegex	= /^\w[\.\w\@-]*$/;
const ssnRegex		= /^\d{3}-\d{2}-\d{4}$/;
const dlRegex		= /^[a-zA-Z]{2}-\w+/; /* driver's license */
const phoneRegex	= /^\d{3}-\d{3}-\d{4}(| \S+.*)$/i;
const nonumRegex	= /^[a-zA-Z]\D*$/; /* no numbers, no beginning whitespace */
const dateRegex	= /^\d{4}-\d{2}-\d{2}/;
const zipRegex		= /^\d{5}(-\d{4}|-?$)/; /* 12345 or 12345-6789 */

In the absence of a short term more elegant solution, if you replace
the definition of all of the regular expressions with /.+/, then any
non-empty content should be accepted. I would suggest keeping at least
the definition of "numRegex" the same, based on how it is used in the
code, but you could probably replace the others like:

const wordRegex	= /.+/;
const unameRegex	= /.+/;
const ssnRegex		= /.+/;
const dlRegex		= /.+/;
const phoneRegex	= /.+/;
const nonumRegex	= /.+/;
const dateRegex	= /.+/;
const zipRegex		= /.+/;

Note that if you replace the definitions in the Evergreen source tree,
you will either have to reinstall Evergreen or make the same
customizations by hand to
/openils/var/web/xul/<dirname>/server/patron/ue_config.js.

-- 
Dan Scott
Laurentian University


More information about the Open-ils-general mailing list