diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-04-15 15:35:20 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-04-15 15:35:20 +0200 |
commit | b3bd4bc384986dcc57e1329ba24aa8ee587015ff (patch) | |
tree | 4bc444fb28a3f512c666b8d4829580cfa39ffcf0 | |
parent | b3ae2208b1ca5d913326042ca9a79aa4c01f8706 (diff) | |
download | nextcloud-server-b3bd4bc384986dcc57e1329ba24aa8ee587015ff.tar.gz nextcloud-server-b3bd4bc384986dcc57e1329ba24aa8ee587015ff.zip |
sanity check on language selection
-rw-r--r-- | settings/ajax/setlanguage.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php index d8d1a860378..e3b00c3bc80 100644 --- a/settings/ajax/setlanguage.php +++ b/settings/ajax/setlanguage.php @@ -7,11 +7,17 @@ $l=OC_L10N::get('settings'); OC_JSON::checkLoggedIn(); + // Get data if( isset( $_POST['lang'] ) ){ + $languageCodes=OC_L10N::findAvailableLanguages(); $lang=$_POST['lang']; - OC_Preferences::setValue( OC_User::getUser(), 'core', 'lang', $lang ); - OC_JSON::success(array("data" => array( "message" => $l->t("Language changed") ))); + if(array_search($lang,$languageCodes) or $lang=='en'){ + OC_Preferences::setValue( OC_User::getUser(), 'core', 'lang', $lang ); + OC_JSON::success(array("data" => array( "message" => $l->t("Language changed") ))); + }else{ + OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") ))); + } }else{ OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") ))); } |