From 479d96b478e3223120c4361ba059d10c36aa372c Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Thu, 23 Mar 2023 21:54:31 +0100 Subject: [PATCH 1/3] More robust if maps is not loaded Signed-off-by: Arne Hamann --- src/report-error-map-action.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/report-error-map-action.js b/src/report-error-map-action.js index bbf3e3527..f8253915d 100644 --- a/src/report-error-map-action.js +++ b/src/report-error-map-action.js @@ -1,9 +1,9 @@ -OCA.Maps.registerMapsAction({ +OCA.Maps?.registerMapsAction({ label: t('maps', 'Report Error'), icon: 'icon-alert-outline', callback: (location) => { const url = `https://www.openstreetmap.org/note/new?lat=${location.latitude}&lon=${location.longitude}#map=18/${location.latitude}/${location.longitude}` - window.open(url, '_blank').focus() + window.open(url, '_blank')?.focus() }, }) From 62dcb1df4d0849ac696b15d655a5de8044279f80 Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Thu, 23 Mar 2023 21:55:04 +0100 Subject: [PATCH 2/3] Updated regex not final Signed-off-by: Arne Hamann --- lib/Service/MyMapsService.php | 6 ++++++ src/components/map/ContactsLayer.vue | 2 +- src/views/App.vue | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Service/MyMapsService.php b/lib/Service/MyMapsService.php index 8f8047050..ecf9237fb 100644 --- a/lib/Service/MyMapsService.php +++ b/lib/Service/MyMapsService.php @@ -143,6 +143,12 @@ private function node2MyMap($node, $userFolder):array{ return $MyMap; } + /** + * @param $userId + * @return array + * @throws NoUserException + * @throws NotPermittedException + */ public function getAllMyMaps($userId){ $userFolder = $this->root->getUserFolder($userId); $MyMaps = []; diff --git a/src/components/map/ContactsLayer.vue b/src/components/map/ContactsLayer.vue index 7450fe3e9..f5c8ab13c 100644 --- a/src/components/map/ContactsLayer.vue +++ b/src/components/map/ContactsLayer.vue @@ -63,7 +63,7 @@ export default { return this.contacts.filter((c) => { if (c.GROUPS) { try { - const cGroups = c.GROUPS.split(/(? { + const cGroups = c.GROUPS.split(/[^\\],/).map((name) => { return name.replace('\\,', ',') }) for (let i = 0; i < cGroups.length; i++) { diff --git a/src/views/App.vue b/src/views/App.vue index f608b6168..a88c82b03 100644 --- a/src/views/App.vue +++ b/src/views/App.vue @@ -1399,7 +1399,8 @@ export default { c.groupList = [] if (c.GROUPS) { try { - const cGroups = c.GROUPS.split(/(? { + // const cGroups = c.GROUPS.split(/(? { + const cGroups = c.GROUPS.split(/[^\\],/).map((name) => { return name.replace('\\,', ',') }) if (cGroups.length > 0) { From a26283556aa12b382c5187b7a961d74482113594 Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Fri, 24 Mar 2023 00:36:55 +0100 Subject: [PATCH 3/3] Correctly handle comma separated groups where the group name might include , and \ Signed-off-by: Arne Hamann --- src/components/map/ContactsLayer.vue | 5 ++--- src/utils.js | 16 ++++++++++++++++ src/views/App.vue | 12 +++--------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/components/map/ContactsLayer.vue b/src/components/map/ContactsLayer.vue index f5c8ab13c..fd1d24145 100644 --- a/src/components/map/ContactsLayer.vue +++ b/src/components/map/ContactsLayer.vue @@ -20,6 +20,7 @@ import Vue2LeafletMarkerCluster from 'vue2-leaflet-markercluster' import ContactLayer from './ContactLayer' import optionsController from '../../optionsController' import {getToken, isPublic} from "../../utils/common"; +import {splitByNonEscapedComma} from "../../utils"; const CONTACT_MARKER_VIEW_SIZE = 40 @@ -63,9 +64,7 @@ export default { return this.contacts.filter((c) => { if (c.GROUPS) { try { - const cGroups = c.GROUPS.split(/[^\\],/).map((name) => { - return name.replace('\\,', ',') - }) + const cGroups = splitByNonEscapedComma(c.GROUPS) for (let i = 0; i < cGroups.length; i++) { // if at least in one enabled group if (this.groups[cGroups[i]].enabled) { diff --git a/src/utils.js b/src/utils.js index 09f7f6ae2..854f511a7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -9,6 +9,21 @@ function dirname(path) { return path.replace(/\\/g, '/').replace(/\/[^\/]*$/, ''); } +function splitByNonEscapedComma(str) { + // As safari doesn't support lookbehind we need to work with reversed strings + return str.split('') + .reverse() + .join('') + .split(/,(?!(?:(?:\\\\)*\\(?!\\)))/) + .map((g) => { + return g.replaceAll(',\\',',') + .replaceAll('\\\\','\\') + .split('') + .reverse() + .join('') + }).reverse() +} + function Timer(callback, mydelay) { var timerId, start, @@ -382,6 +397,7 @@ export const accented = { export { basename, dirname, + splitByNonEscapedComma, Timer, getLetterColor, hslToRgb, diff --git a/src/views/App.vue b/src/views/App.vue index a88c82b03..4a51a7f8f 100644 --- a/src/views/App.vue +++ b/src/views/App.vue @@ -230,11 +230,10 @@ import AppNavigationTracksItem from '../components/AppNavigationTracksItem' import AppNavigationDevicesItem from '../components/AppNavigationDevicesItem' import AppNavigationMyMapsItem from '../components/AppNavigationMyMapsItem' import optionsController from '../optionsController' -import { getLetterColor, hslToRgb, Timer, getDeviceInfoFromUserAgent2, isComputer, isPhone } from '../utils' +import { getLetterColor, hslToRgb, Timer, getDeviceInfoFromUserAgent2, isComputer, isPhone, splitByNonEscapedComma } from '../utils' import { binSearch, getToken, isPublic } from '../utils/common' import { poiSearchData } from '../utils/poiData' import { processGpx } from '../tracksUtils' - import L from 'leaflet' import { geoToLatLng, getFormattedADR } from '../utils/mapUtils' import * as network from '../network' @@ -1316,9 +1315,7 @@ export default { const contactsInGroup = this.contacts.filter((c) => { if (c.GROUPS) { try { - const cGroups = c.GROUPS.split(/[^\\],/).map((name) => { - return name.replace('\\,', ',') - }) + const cGroups = splitByNonEscapedComma(c.GROUPS) for (let i = 0; i < cGroups.length; i++) { // if at least in one enabled group if (cGroups[i] === group) { @@ -1399,10 +1396,7 @@ export default { c.groupList = [] if (c.GROUPS) { try { - // const cGroups = c.GROUPS.split(/(? { - const cGroups = c.GROUPS.split(/[^\\],/).map((name) => { - return name.replace('\\,', ',') - }) + const cGroups = splitByNonEscapedComma(c.GROUPS) if (cGroups.length > 0) { cGroups.forEach((g) => { c.groupList.push(g)