Skip to content

Commit

Permalink
Domains: Convert characters to basic Latin, when possible
Browse files Browse the repository at this point in the history
The WHOIS specification does not define the required character set to be
used, but most WHOIS servers use just the basic Latin character set, so
that's what we enforce too. This change automagically converts other
characters to their basic Latin versions using the `deburr` method from
Lodash. So `ś` becomes `s`, `ą` -> `a`, etc.

Fixes #12559
  • Loading branch information
Igor Klimer authored and klimeryk committed Apr 4, 2017
1 parent 2c2f1bc commit 898a9fd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client/my-sites/upgrades/checkout/domain-details-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
*/
import React from 'react';
import classNames from 'classnames';
import { camelCase, head, kebabCase, map, omit, reduce } from 'lodash';
import {
camelCase,
deburr,
head,
kebabCase,
map,
omit,
reduce,
} from 'lodash';

/**
* Internal dependencies
Expand Down Expand Up @@ -73,7 +81,7 @@ export default React.createClass( {
const sanitizedFieldValues = Object.assign( {}, fieldValues );
this.fieldNames.forEach( ( fieldName ) => {
if ( typeof fieldValues[ fieldName ] === 'string' ) {
sanitizedFieldValues[ fieldName ] = fieldValues[ fieldName ].trim();
sanitizedFieldValues[ fieldName ] = deburr( fieldValues[ fieldName ].trim() );
if ( fieldName === 'postalCode' ) {
sanitizedFieldValues[ fieldName ] = sanitizedFieldValues[ fieldName ].toUpperCase();
}
Expand Down

0 comments on commit 898a9fd

Please sign in to comment.