Invalid information is stored and cannot be deleted

Yes, that is because the validate function is too restrictive:

It should imho look like this:

/**
 * Validate the URL input
 *
 * @param {string} input the input
 * @return {boolean}
 */
export function validateUrl(input) {
	// Treat null/undefined/empty (after trimming) as valid so the user can remove the URL
	if (input === null || input === undefined) return true
	const value = String(input).trim()
	if (value === '') return true

	try {
		// eslint-disable-next-line no-new
		new URL(value)
		return true
	} catch (e) {
		return false
	}
}

If you want users to be able to enter www.example.com without https://, you can automatically prepend https:// before using new URL():
(untested):

/**
 * Validate the URL input, accept empty values and scheme-less hosts
 *
 * @param {string} input the input
 * @return {boolean}
 */
export function validateUrl(input) {
	// Treat null/undefined/empty (after trimming) as valid so the user can remove the URL
	if (input === null || input === undefined) return true
	let value = String(input).trim()
	if (value === '') return true

	// If there's no scheme like "http:", assume https
	// This accepts inputs like "www.example.com" or "example.com"
	if (!/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value)) {
		value = 'https://' + value
	}

	try {
		// eslint-disable-next-line no-new
		new URL(value)
		return true
	} catch (e) {
		return false
	}
}

In the last example, https:// is only prepended if there is no scheme in the input. If the user enters http://example.com, http:// is retained, and new URL() should validate it normally.


@bb77: If you want to remove the Website data from your personal settings, you should remove it from the database with this query (replace $user_id):

MySQL:

UPDATE oc_accounts SET data = JSON_SET(data, '$.website.value', '') WHERE uid = '$user_id';

(PostgreSQL is different)

and then run

occ dav:sync-system-addressbook

After that the “Website” field is empty again.

h.t.h.


ernolf