Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Invites: Ensure that user inputted data is decoded" #1250

Merged
merged 1 commit into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions client/lib/invites/reducers/invites-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,22 @@
* External dependencies
*/
import { fromJS } from 'immutable';
import mapValues from 'lodash/object/mapValues';
import pick from 'lodash/object/pick';

/**
* Internal dependencies
*/
import { action as ActionTypes } from 'lib/invites/constants';
import { decodeEntities } from 'lib/formatting';

const initialState = fromJS( {
list: {},
errors: {}
} );

function filterObject( object ) {
return mapValues( object, value => {
if ( 'object' === typeof value ) {
return filterObject( value );
}

return value ? decodeEntities( value ) : value;
} );
}

function filterInvite( invite ) {
return mapValues( pick( invite, [ 'invite', 'inviter', 'blog_details' ] ), filterObject );
}

const reducer = ( state = initialState, payload ) => {
const { action } = payload;
switch ( action.type ) {
case ActionTypes.RECEIVE_INVITE:
return state.setIn( [ 'list', action.siteId, action.inviteKey ], filterInvite( action.data ) );
return state.setIn( [ 'list', action.siteId, action.inviteKey ], action.data );
case ActionTypes.RECEIVE_INVITE_ERROR:
return state.setIn( [ 'errors', action.siteId, action.inviteKey ], action.error );
}
Expand Down
21 changes: 4 additions & 17 deletions server/user-bootstrap/shared-utils.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
/**
* External dependencies
*/
import assign from 'lodash/object/assign';
import contains from 'lodash/collection/contains';
var assign = require( 'lodash/object/assign' );

/**
* Internal dependencies
*/
import config from 'config';
import { decodeEntities } from 'lib/formatting';

/**
* Module variables
*/
const languages = config( 'languages' );
var config = require( 'config' ),
languages = config( 'languages' );

function getLanguage( slug ) {
var len = languages.length,
Expand Down Expand Up @@ -55,17 +49,10 @@ module.exports = {
'logout_URL',
'primary_blog_url',
'meta',
],
decodeWhitelist = [
'display_name',
'description',
'user_URL'
];

allowedKeys.forEach( function( key ) {
user[ key ] = obj[ key ] && contains( decodeWhitelist, key )
? decodeEntities( obj[ key ] )
: obj[ key ];
user[ key ] = obj[ key ];
} );

return assign( user, this.getComputedAttributes( obj ) );
Expand Down