From afd4a3933790239e3f43671a08295b0550102298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 19 Jan 2023 00:15:32 +0100 Subject: [PATCH] Friendica, version parsing fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/edit-profile/index.tsx | 3 ++- app/soapbox/utils/features.ts | 9 +++++---- app/soapbox/utils/html.ts | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/soapbox/features/edit-profile/index.tsx b/app/soapbox/features/edit-profile/index.tsx index 000c79aaa..6f14c6354 100644 --- a/app/soapbox/features/edit-profile/index.tsx +++ b/app/soapbox/features/edit-profile/index.tsx @@ -1,3 +1,4 @@ +import { List as ImmutableList } from 'immutable'; import React, { useState, useEffect, useMemo } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; @@ -125,7 +126,7 @@ const accountToCredentials = (account: Account): AccountCredentials => { display_name: account.display_name, note: account.source.get('note'), locked: account.locked, - fields_attributes: [...account.source.get>('fields', []).toJS()], + fields_attributes: [...account.source.get>('fields', ImmutableList()).toJS()], stranger_notifications: account.getIn(['pleroma', 'notification_settings', 'block_from_strangers']) === true, accepts_email_list: account.getIn(['pleroma', 'accepts_email_list']) === true, hide_followers: hideNetwork, diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index 08f6a50b0..3a898b7d9 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -624,6 +624,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see GET /api/v1/timelines/public */ publicTimeline: any([ + v.software === FRIENDICA, v.software === MASTODON, v.software === PLEROMA, v.software === TAKAHE, @@ -739,7 +740,6 @@ const getInstanceFeatures = (instance: Instance) => { * @see {@link https://docs.joinmastodon.org/methods/accounts/suggestions/} */ suggestions: any([ - v.software === FRIENDICA, v.software === MASTODON && gte(v.compatVersion, '2.4.3'), v.software === TRUTHSOCIAL, features.includes('v2_suggestions'), @@ -750,6 +750,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see GET /api/v2/suggestions */ suggestionsV2: any([ + v.software === FRIENDICA, v.software === MASTODON && gte(v.compatVersion, '3.4.0'), v.software === TRUTHSOCIAL, features.includes('v2_suggestions'), @@ -830,9 +831,9 @@ export const parseVersion = (version: string): Backend => { const regex = /^([\w+.]*)(?: \(compatible; ([\w]*) (.*)\))?$/; const match = regex.exec(version); - const semver = match ? semverParse(semverCoerce(match[3] || match[1], { loose: true })) : null; - const compat = match ? semverParse(match[1]) : null; - + const semverString = match && (match[3] || match[1]); + const semver = match ? semverParse(semverString) || semverCoerce(semverString) : null; + const compat = match ? semverParse(match[1]) || semverCoerce(match[1]) : null; if (match && semver && compat) { return { diff --git a/app/soapbox/utils/html.ts b/app/soapbox/utils/html.ts index 32a47caed..98754bab0 100644 --- a/app/soapbox/utils/html.ts +++ b/app/soapbox/utils/html.ts @@ -1,6 +1,6 @@ /** Convert HTML to a plaintext representation, preserving whitespace. */ // NB: This function can still return unsafe HTML -export const unescapeHTML = (html: string): string => { +export const unescapeHTML = (html: string = ''): string => { const wrapper = document.createElement('div'); wrapper.innerHTML = html.replace(//g, '\n').replace(/<\/p><[^>]*>/g, '\n\n').replace(/<[^>]*>/g, ''); return wrapper.textContent || '';