CVE-2018-12030 (published 2018-06-15T16:29Z)

Chevereto Free before 1.0.13 has XSS.

Severity: LOW
CVSS v2 base score: 3.5 (AV:N/AC:M/Au:S/C:N/I:P/A:N)
CVSS v3 base score: 5.4, MEDIUM (CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/Chevereto/Chevereto-Free
commit_details: repo_url: https://github.com/Chevereto/Chevereto-Free
author: rodolfoberrios
author_date: 2018-06-06 17:00:33-04:00
msg: v1.0.13

Fixed post handling in /settings (name, bio)
repository: repo_url: https://github.com/Chevereto/Chevereto-Free
repo_name: rodber/chevereto-free
description: Self-hosted image sharing software, your own Flickr/Imgur with your very own rules. 👍 Go to chevereto/chevereto for newer Chevereto releases.
repo_language: PHP
owner: Chevereto
file_changes: filename: app.php
change_type: ModificationType.MODIFY
diff: @@ -1,6 +1,6 @@
 <?php
 define('G_APP_NAME', 'Chevereto Free');
-define('G_APP_VERSION', '1.0.12');
+define('G_APP_VERSION', '1.0.13');
 define('G_APP_GITHUB_OWNER', 'Chevereto');
 define('G_APP_GITHUB_REPO', 'Chevereto-Free');
 define('G_APP_GITHUB_REPO_URL', 'https://github.com/' . G_APP_GITHUB_OWNER . '/' . G_APP_GITHUB_REPO);

programming_language: PHP
filename: installer.php
change_type: ModificationType.MODIFY
diff: @@ -244,6 +244,7 @@
 		],
 		'1.0.11' => NULL,
 		'1.0.12' => NULL,
+		'1.0.13' => NULL,
 	];
 	// Settings that must be renamed from NAME to NEW NAME and DELETE old NAME
 	$settings_rename = [];

programming_language: PHP
filename: route.settings.php
change_type: ModificationType.MODIFY
diff: @@ -9,7 +9,7 @@
 			<inbox@rodolfoberrios.com>
 
   Copyright (C) Rodolfo Berrios A. All rights reserved.
-  
+
   BY USING THIS SOFTWARE YOU DECLARE TO ACCEPT THE CHEVERETO EULA
   http://chevereto.com/license
 
@@ -17,46 +17,46 @@
 
 $route = function($handler) {
 	try {
-		
+
 		if($_POST and !$handler::checkAuthToken($_REQUEST['auth_token'])) {
 			$handler->template = 'request-denied';
 			return;
 		}
-		
+
 		$logged_user = CHV\Login::getUser();
-		
+
 		if(!$logged_user) {
 			G\redirect('login');
 		}
-		
+
 		// User status override redirect
 		CHV\User::statusRedirect($logged_user['status']);
-		
+
 		// Dashboard hack
 		$handler->template = 'settings';
 		$is_dashboard_user = $handler::getCond('dashboard_user');
-		
+
 		// Request log
 		if(!$is_dashboard_user) {
 			$request_log = CHV\Requestlog::getCounts('account-edit', 'fail');
 		}
-		
+
 		// Editable values
 		$allowed_to_edit = ['name', 'username', 'email', 'avatar_filename', 'website', 'background_filename', 'timezone', 'language', 'status', 'is_admin', 'image_keep_exif', 'image_expiration', 'newsletter_subscribe', 'bio', 'show_nsfw_listings', 'is_private'];
-		
+
         if(CHV\getSetting('enable_expirable_uploads')) {
             unset($allowed_to_edit['image_expiration']);
         }
-        
+
 		// User handle
 		$user = $is_dashboard_user ? CHV\User::getSingle($handler->request[1], 'id') : $logged_user;
 		$is_owner = $user['id'] == CHV\Login::getUser()['id'];
-		
+
 		// Update the lang displayed on change
 		if(in_array('language', $allowed_to_edit) and isset($_POST['language']) and $logged_user['language'] !== $_POST['language'] and $logged_user['id'] == $user['id'] and array_key_exists($_POST['language'], CHV\L10n::getEnabledLanguages())) {
 			CHV\L10n::processTranslation($_POST['language']);
 		}
-		
+
 		// Settings routes
 		$routes = [
 			'account'			=> _s('Account'),
@@ -65,26 +65,26 @@
 			'homepage' 			=> _s('Homepage')
 		];
 		$default_route = 'account';
-		
+
 		if(CHV\getSetting('website_mode') == 'personal' and CHV\getSetting('website_mode_personal_routing') !== '/' and $logged_user['id'] == CHV\getSetting('website_mode_personal_uid')) {
 			$route_homepage = TRUE;
 		}
-		
+
 		$is_email_required = TRUE;
 		// Don't require email for admin when editing users
 		if($handler::getCond('admin') AND !$is_owner) {
 			$is_email_required = FALSE;
 		}
-		
+
 		$doing_level = $is_dashboard_user ? 2 : 0;
 		$doing = $handler->request[$doing_level];
 
 		if(!$user or $handler->request[$doing_level+1] or (!is_null($doing) and !array_key_exists($doing, $routes))) {
 			return $handler->issue404();
 		}
-		
+
 		if($doing == '') $doing = $default_route;
-		
+
 		// Populate the routes
 		foreach($routes as $route => $label) {
 			$aux = str_replace('_', '-', $route);
@@ -101,42 +101,42 @@
 				'current' => $handler::getCond('settings_'.$aux)
 			);
 		}
-		
+
 		$handler::setVar('settings_menu', $settings_menu);
-		
+
 		if(!array_key_exists($doing, $routes)) {
 			return $handler->issue404();
 		}
-		
+
 		// Safe print $_POST
-		$SAFE_POST = $handler::getVar('safe_post');	
-		
+		$SAFE_POST = $handler::getVar('safe_post');
+
 		// conds
 		$is_error = false;
 		$is_changed = false;
 		$captcha_needed = false;
-		
+
 		// vars
 		$input_errors = array();
 		$error_message = NULL;
 		$changed_email_message = NULL;
-		
+
 		if($_POST) {
-			
+
 			$field_limits = 255;
-			
+
 			foreach($allowed_to_edit as $k) {
 				if($_POST[$k]) {
 					$_POST[$k] = substr($_POST[$k], 0, $field_limits);
 				}
 			}
-			
+
 			// Input validations
 			switch($doing) {
-				
+
 				case NULL:
 				case 'account':
-					
+
 					$checkboxes = ['upload_image_exif', 'newsletter_subscribe', 'show_nsfw_listings', 'is_private'];
 					foreach($checkboxes as $k) {
 						if(!isset($_POST[$k])) {
@@ -144,9 +144,9 @@
 						}
 						$_POST[$k] = in_array($_POST[$k], ['On', 1]) ? 1 : 0;
 					}
-					
+
 					G\nullify_string($_POST['image_expiration']);
-                    
+
 					$__post = [];
 					$__safe_post = [];
 					foreach(['username', 'email'] as $v) {
@@ -156,25 +156,25 @@
 							$__safe_post[$v] = G\safe_html($_POST[$v]);
 						}
 					}
-					
+
 					$handler::updateVar('post', $__post);
 					$handler::updateVar('safe_post', $__safe_post);
-					
+
 					if(!CHV\User::isValidUsername($_POST['username'])) {
 						$input_errors['username'] = _s('Invalid username');
 					}
-					
+
 					if($is_email_required and !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
 						$input_errors['email'] = _s('Invalid email');
 					}
-                    
+
                     if(CHV\getSetting('enable_expirable_uploads')) {
                         // Image expire time
                         if($_POST['image_expiration'] !== NULL && (!G\dateinterval($_POST['image_expiration']) || !array_key_exists($_POST['image_expiration'], CHV\Image::getAvailableExpirations()))) {
                             $input_errors['image_expiration'] = _s('Invalid image expiration: %s', $_POST['image_expiration']);
                         }
                     }
-                    
+
 					if(!array_key_exists($_POST['language'], CHV\get_available_languages())) {
 						$_POST['language'] = CHV\getSetting('default_language');
 					}
@@ -185,17 +185,17 @@
 					if(count($input_errors) > 0) {
 						$is_error = true;
 					}
-					
+
 					if(!$is_error) {
-						
+
 						$user_db = CHV\DB::get('users', ['username' => $_POST['username'], 'email' => $_POST['email']], 'OR', NULL);
-						
+
 						if($user_db) {
-							
+
 							foreach($user_db as $row) {
-								
+
 								if($row['user_id'] == $user['id']) continue; // Same guy?
-								
+
 								// Invalid user, check the time
 								if(!in_array($row['user_status'], ['valid', 'banned'])) { // Don't touch the valid and banned users
 									$must_delete_old_user = false;
@@ -215,7 +215,7 @@
 										continue;
 									}
 								}
-								
+
 								// Username taken?
 								if(G\timing_safe_compare($row['user_username'], $_POST['username']) and $user['username'] !== $row['user_username']) {
 									$input_errors['username'] = 'Username already being used';
@@ -226,7 +226,7 @@
 									$input_errors['email'] = _s('Email already being used');
 								}
 							}
-							
+
 							if(count($input_errors) > 0) {
 								$is_error = true;
 							}
@@ -235,10 +235,10 @@
 
 					// Email MUST be validated (two steps)
 					if(!$is_error && !empty($_POST['email']) && !G\timing_safe_compare($user['email'], $_POST['email'])) {
-						
+
 						// Delete any old confirmation
 						CHV\Confirmation::delete(['type' => 'account-change-email', 'user_id' => $user['id']]);
-						
+
 						// Generate the thing
 						$hashed_token = CHV\generate_hashed_token($user['id']);
 						$insert_email_confirm = CHV\Confirmation::insert([
@@ -249,20 +249,20 @@
 							'extra'			=> $_POST['email']
 						]);
 						$email_confirm_link = G\get_base_url('account/change-email-confirm/?token='.$hashed_token['public_token_format']);
-						$changed_email_message = _s('An email has been sent to %s with instructions to activate this email', $SAFE_POST['email']);	
-						
+						$changed_email_message = _s('An email has been sent to %s with instructions to activate this email', $SAFE_POST['email']);
+
 						// Build the mail global
 						global $theme_mail;
 						$theme_mail = [
 							'user' => $user,
 							'link' => $email_confirm_link
 						];
-						
+
 						ob_start();
 						require_once(G_APP_PATH_THEME . 'mails/account-change-email.php');
 						$mail_body = ob_get_contents();
 						ob_end_clean();
-						
+
 						$mail['subject'] = _s('Confirmation required at %s', CHV\getSettings()['website_name']);
 						$mail['message'] = $mail_body;
 
@@ -273,13 +273,13 @@
 						} catch(Exception $e) {
 							echo($e->getMessage());
 						}
-						
+
 						unset($_POST['email']);
-						
+
 					}
-					
+
 				break;
-				
+
 				case 'profile':
 					if(!preg_match('/^.{1,60}$/', $_POST['name'])) {
 						$input_errors['name'] = _s('Invalid name');
@@ -288,9 +288,9 @@
 						$input_errors['website'] = _s('Invalid website');
 					}
 				break;
-				
+
 				case 'password':
-					
+
 					if(!$is_dashboard_user) {
 						if($user['login']['password'] && !password_verify($_POST['current-password'], $user['login']['password']['secret'])) {
 							$input_errors['current-password'] = _s('Wrong password');
@@ -301,23 +301,23 @@
 							}
 						}
 					}
-				
+
 					if(!preg_match('/'.CHV\getSetting('user_password_pattern').'/', $_POST['new-password'])) {
 						$input_errors['new-password'] = _s('Invalid password');
 					}
-					
+
 					if($_POST['new-password'] !== $_POST['new-password-confirm']) {
 						$input_errors['new-password-confirm'] = _s("Passwords don't match");
 					}
 
 				break;
-				
+
 				case 'homepage':
 					if(!array_key_exists($doing, $routes)) { // Nope
 						$handler->issue404();
 					}
 					$allowed_to_edit = ['homepage_title_html', 'homepage_paragraph_html', 'homepage_cta_html'];
-					
+
 					// Protect editing
 					$editing_array = G\array_filter_array($_POST, $allowed_to_edit, 'exclusion');
 					$update_settings = [];
@@ -325,7 +325,7 @@
 						if(!array_key_exists($k, CHV\Settings::get()) or CHV\Settings::get($k) == $editing_array[$k]) continue;
 						$update_settings[$k] = $editing_array[$k];
 					}
-					
+
 					// Update settings (if any)
 					if($update_settings) {
 						$db = CHV\DB::getInstance();
@@ -344,21 +344,21 @@
 						}
 					}
 				break;
-				
+
 				default:
 					$handler->issue404();
 				break;
 			}
-			
+
 			if(count($input_errors) > 0) {
 				$is_error = true;
 			}
-			
+
 			if(!$is_error) {
-			
+
 				// Account and profile changes
 				if(in_array($doing, [NULL, 'account', 'profile'])) {
-					
+
 					// Detect changes
 					foreach($_POST as $k => $v) {
 						if($user[$k] !== $v) {
@@ -367,10 +367,10 @@
 					}
 
 					if($is_changed) {
-						
+
 						// Protect editing
 						$editing_array = G\array_filter_array($_POST, $allowed_to_edit, 'exclusion');
-						
+
 						if(!$is_dashboard_user) {
 							unset($editing_array['status'], $editing_array['is_admin']);
 						} else {
@@ -392,9 +392,12 @@
 
 						if(CHV\User::update($user['id'], $editing_array)) {
 							$user = array_merge($user, $editing_array);
-							$handler::updateVar('safe_post', ['name' => CHV\User::sanitizeUserName($_POST['name'])]);
+							// 'name' gets sanitized on User::update, this update safe_post to reflect the actual value
+							$handler::updateVar('safe_post', [
+								'name' => G\safe_html($user['name']),
+							]);
 						}
-						
+
 						if(!$is_dashboard_user) {
 							$logged_user = CHV\Login::login($user['id'], $_SESSION['login']['type']);
 						} else {
@@ -403,39 +406,39 @@
 						$changed_message = _s('Changes have been saved.');
 					}
 				}
-				
+
 				// Update/create password
 				if($doing == 'password') {
-					
+
 					if($user['login']['password']) {
-					
+
 						// Delete any old cookie/session login for this user
 						CHV\Login::delete(['type' => 'cookie', 'user_id' => $user['id']]);
 						CHV\Login::delete(['type' => 'session', 'user_id' => $user['id']]);
-						
+
 						// Insert the new login DB if needed
 						if(!$is_dashboard_user and $_COOKIE['KEEP_LOGIN']) {
 							CHV\Login::insert(['type' => 'cookie', 'user_id' => $user['id']]);
 						}
-												
+
 						$is_changed = CHV\Login::changePassword($user['id'], $_POST['new-password']); // This inserts the session login
 						$changed_message = _s('Password has been changed');
-						
+
 					} else { // Insert
-						
+
 						$is_changed = CHV\Login::addPassword($user['id'], $_POST['new-password']);
 						$changed_message = _s('Password has been created.');
 						if(!$is_dashboard_user or $logged_user['id'] == $user['id']) {
 							$logged_user = CHV\Login::login($user['id'], 'password');
 						}
 					}
-					
+
 					$unsets = array('current-password', 'new-password', 'new-password-confirm');
 					foreach($unsets as $unset) {
 						$handler::updateVar('safe_post', [$unset => NULL]);
 					}
 				}
-				
+
 			} else {
 				if(in_array($doing, array('', 'account')) and !$is_dashboard_user) {
 					CHV\Requestlog::insert(array('type' => 'account-edit', 'result' => 'fail'));
@@ -444,29 +447,29 @@
 			}
 
 		}
-		
+
 		$handler::setCond('settings_linked_accounts', FALSE);
-		
+
 		$handler::setCond('owner', $is_owner);
 		$handler::setCond('error', $is_error);
 		$handler::setCond('changed', $is_changed);
 		$handler::setCond('captcha_needed', $captcha_needed);
 		$handler::setCond('dashboard_user', $is_dashboard_user);
 		$handler::setCond('email_required', $is_email_required);
-		
+
 		if($captcha_needed and !$handler::getVar('recaptcha_html')) {
 			$handler::setVar('recaptcha_html', CHV\Render\get_recaptcha_html());
 		}
-		
+
 		$handler::setVar('pre_doctitle', $is_dashboard_user ? _s('Settings for %s', $user['username']) : _s('Settings'));
-		
+
 		$handler::setVar('error',  $error_message);
 		$handler::setVar('input_errors', $input_errors);
 		$handler::setVar('changed_message', $changed_message);
 		$handler::setVar('changed_email_message', $changed_email_message);
 		$handler::setVar('user', $is_dashboard_user ? $user : $logged_user);
 		$handler::setVar('safe_html_user', G\safe_html($handler::getVar('user')));
-		
+
 	} catch(Exception $e) {
 		G\exception_to_error($e);
 	}

programming_language: PHP
filename: settings.php
change_type: ModificationType.MODIFY
diff: @@ -2,9 +2,9 @@
 <?php G\Render\include_theme_header(); ?>
 
 <div class="content-width">
-    
+
 	<div class="c24 center-box">
-		
+
 		<div class="header header-tabs default-margin-bottom">
 			<h1><?php echo get_pre_doctitle(); ?></h1>
 			<div class="hidden phone-show phablet-show">
@@ -40,9 +40,9 @@
 				}
 			?>
 		</div>
-		
+
 		<div class="form-content">
-			
+
 			<ul class="content-tabs c5 content-tabs-vertical phone-hide phablet-hide">
 				<?php
 					foreach(get_settings_menu() as $item) {
@@ -52,11 +52,11 @@
 					}
 				?>
 			</ul>
-		
+
 			<form data-content="main-form" class="tabbed-input-column" method="post" data-type="<?php echo get_setting(); ?>" data-action="validate">
-				
+
 				<?php echo G\Render\get_input_auth_token(); ?>
-				
+
 				<?php
 					if(is_settings_account()) {
 
@@ -99,7 +99,7 @@
 						}
 					?>
 				</ul>
-				
+
 				<div class="c5 phablet-c1">
 					<div class="input-label">
 						<label for="status"><?php _se('Status'); ?></label>
@@ -132,9 +132,9 @@
 						</select>
 					</div>
 				</div>
-				
+
 				<hr class="line-separator"></hr>
-				
+
 				<?php
 						}
 				?>
@@ -158,9 +158,9 @@
 						<?php if(get_changed_email_message()) { ?><div class="input-below highlight padding-5"><?php echo get_changed_email_message(); ?></div><?php } ?>
 					</div>
 				</div>
-				
+
 				<hr class="line-separator"></hr>
-				
+
 				<?php if(CHV\getSetting('enable_expirable_uploads')) { ?>
                 <div class="input-label">
                     <label for="image_expiration"><?php _se('Auto delete uploads'); ?></label>
@@ -176,9 +176,9 @@
                 </div>
 
                 <hr class="line-separator"></hr>
-				
+
 				<?php } ?>
-				
+
                 <?php if(CHV\getSetting('upload_image_exif_user_setting')) { ?>
                 <div class="input-label">
                     <label><?php _se('Image Exif data'); ?></label>
@@ -189,7 +189,7 @@
 					]); ?>
                 </div>
                 <?php } ?>
-        
+
 				<div class="input-label">
 					<label><?php _se('Newsletter'); ?></label>
 					<?php echo CHV\Render\get_checkbox_html([
@@ -198,7 +198,7 @@
 						'checked'	=> ((bool)(get_safe_post() ? get_safe_post()['newsletter_subscribe'] : get_user()['newsletter_subscribe']))
 					]); ?>
 				</div>
-				
+
 				<div class="input-label">
 					<label><?php _se('Content settings'); ?></label>
 					<?php echo CHV\Render\get_checkbox_html([
@@ -207,9 +207,9 @@
 						'checked'	=> ((bool)(get_safe_post() ? get_safe_post()['show_nsfw_listings'] : get_user()['show_nsfw_listings']))
 					]); ?>
 				</div>
-				
+
 				<hr class="line-separator"></hr>
-				
+
 				<?php if(CHV\getSetting('language_chooser_enable')) { ?>
 				<div class="c5 phablet-c1">
 					<div class="input-label">
@@ -226,27 +226,27 @@
 					</div>
 				</div>
 				<?php } ?>
-				
-				<?php 
+
+				<?php
 
 				$zones = timezone_identifiers_list();
-				
+
 				foreach ($zones as $zone) {
 					$zone = explode('/', $zone);
-					if(in_array($zone[0], array("Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Australia", "Europe", "Indian", "Pacific"))) {      
+					if(in_array($zone[0], array("Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Australia", "Europe", "Indian", "Pacific"))) {
 						if (isset($zone[1]) != '') {
 							$regions[$zone[0]][$zone[0]. '/' . $zone[1]] = str_replace('_', ' ', $zone[1]);
-						} 
+						}
 					}
 				}
-				
+
 				?>
-				
+
 				<div class="input-label">
 					<label for="timezone"><?php _se('Timezone'); ?></label>
-					
+
 					<div class="overflow-auto">
-					
+
 						<select id="timezone-region" class="c5 phablet-c1 grid-columns margin-right-10 phone-margin-bottom-10 phablet-margin-bottom-10 text-input" data-combo="timezone-combo">
 							<option><?php _se('Select region'); ?></option>
 							<?php
@@ -276,15 +276,15 @@
 						</div>
 
 					</div>
-					
+
 					<input type="hidden" id="timezone" name="timezone" data-content="timezone" data-highlight="#timezone-region" value="<?php echo get_user()["timezone"]; ?>" required>
-					
+
 				</div>
 
 				<?php } ?>
-				
+
 				<?php if(is_settings_password()) { ?>
-				
+
 				<?php
 					// User has password
 					if(get_user()["login"]["password"] !== NULL) {
@@ -335,7 +335,7 @@
 					}
 				?>
 				<?php } ?>
-				
+
 				<?php if(is_settings_profile()) { ?>
 				<div class="c19 phablet-c1">
 					<div class="input-upload user-settings-avatar">
@@ -359,7 +359,7 @@
 						<input id="user-avatar-upload" data-content="user-avatar-upload-input" class="hidden-visibility" type="file" accept="image/*">
 					</div>
 				</div>
-				
+
 				<div class="input-label">
                     <label><?php _se('Privacy'); ?></label>
 					<?php echo CHV\Render\get_checkbox_html([
@@ -367,9 +367,9 @@
 						'label'		=> _s('Make my profile and identity totally private'),
 						'tooltip'	=> _s('Enable this if you want to act like an anonymous user'),
 						'checked'	=> ((bool)(get_safe_post() ? get_safe_post()['is_private'] : get_user()['is_private']))
-					]); ?>      
+					]); ?>
 				</div>
-				
+
 				<div class="c9 phablet-c1">
 					<div class="input-label">
 						<label for="name"><?php _se('Name'); ?></label>
@@ -384,12 +384,12 @@
 					</div>
 					<div class="input-label">
 						<label for="bio"><?php _se('Bio'); ?></label>
-						<textarea name="bio" id="bio" class="resize-vertical" placeholder="<?php _se('Tell us a little bit about you'); ?>" maxlength="255"><?php echo get_safe_post() ? get_safe_post()["bio"] : get_user()["bio"]; ?></textarea>
+						<textarea name="bio" id="bio" class="resize-vertical" placeholder="<?php _se('Tell us a little bit about you'); ?>" maxlength="255"><?php echo get_safe_post() ? get_safe_post()["bio"] : get_safe_html_user()["bio"]; ?></textarea>
 						<span class="input-warning red-warning"><?php echo get_input_errors()["bio"]; ?></span>
 					</div>
 				</div>
 				<?php } ?>
-				
+
 				<?php
 					if(is_settings_linked_accounts()) {
 
@@ -424,7 +424,7 @@
 				<?php
 						}
 				?>
-				
+
 				<?php
 						if(!is_dashboard_user()) {
 							foreach(get_available_connections() as $connection => $label) {
@@ -437,49 +437,49 @@
 							}
 						}
 				?>
-				
+
 				<?php } ?>
-				
+
 				<?php if(is_settings_homepage()) { ?>
 				<div class="input-label">
 					<label for="homepage_title_html"><?php _se('Title'); ?></label>
 					<div class="c12 phablet-c1"><textarea type="text" name="homepage_title_html" id="homepage_title_html" class="text-input r2 resize-vertical" placeholder="<?php echo get_user()['name']; ?>"><?php echo CHV\Settings::get('homepage_title_html'); ?></textarea></div>
 					<span class="input-warning red-warning"><?php echo get_input_errors()["homepage_title_html"]; ?></span>
 				</div>
-				
+
 				<div class="input-label">
 					<label for="homepage_paragraph_html"><?php _se('Paragraph'); ?></label>
 					<div class="c12 phablet-c1"><textarea type="text" name="homepage_paragraph_html" id="homepage_paragraph_html" class="text-input r2 resize-vertical" placeholder="<?php _se('Feel free to browse and discover all my shared images and albums.'); ?>"><?php echo CHV\Settings::get('homepage_paragraph_html'); ?></textarea></div>
 					<span class="input-warning red-warning"><?php echo get_input_errors()["homepage_paragraph_html"]; ?></span>
 				</div>
-				
+
 				<div class="input-label">
 					<label for="homepage_cta_html"><?php _se('Button'); ?></label>
 					<div class="c12 phablet-c1"><textarea type="text" name="homepage_cta_html" id="homepage_cta_html" class="text-input r2 resize-vertical" placeholder="<?php _se('View all my images'); ?>"><?php echo CHV\Settings::get('homepage_cta_html'); ?></textarea></div>
 					<span class="input-warning red-warning"><?php echo get_input_errors()["homepage_cta_html"]; ?></span>
 				</div>
 				<?php } ?>
-				
+
 				<hr class="line-separator"></hr>
-				
+
 				<?php if(is_captcha_needed()) { ?>
 				<div class="input-label">
 					<label for="recaptcha_response_field">reCAPTCHA</label>
 					<?php echo get_recaptcha_html(); ?>
 				</div>
 				<?php } ?>
-				
+
 				<?php if(!is_settings_linked_accounts()) { ?>
 				<div class="btn-container">
 					<button class="btn btn-input default" type="submit"><?php _se('Save changes'); ?></button> <span class="btn-alt"><?php _se('or'); ?> <a href="<?php echo get_user()["url"]; ?>"><?php _se('cancel'); ?></a></span>
 				</div>
 				<?php } ?>
-			
+
 			</form>
 		</div>
-	
+
 	</div>
-    
+
 </div>
 
 <?php if(get_post() and (is_changed() or is_error())) { ?>

programming_language: PHP