Merge branch 'staging' of https://gitlab.com/sottye/hytha35 into staging

This commit is contained in:
Narindra ezway 2025-04-24 16:54:42 +03:00
commit 3c9740e0ba
2 changed files with 31 additions and 5 deletions

View File

@ -141,11 +141,31 @@ const setCustomKeyValuesArrayToIcsAndReturnIcs = (ics, keyValueArray) => {
return ics;
}
const escapeICSField = (value) => {
return value
.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\n')
.replace(/,/g, '\\,')
.replace(/;/g, '\\;');
}
const foldICSLines = (line) => {
const folded = [];
while (line.length > 75) {
folded.push(line.slice(0, 75));
line = ' ' + line.slice(75); // continuation line starts with a space
}
folded.push(line);
return folded.join('\r\n');
}
export {
getDefaultCalendarObjectObject,
mapCDavObjectToCalendarObject,
mapCalendarJsToCalendarObject,
setCustomKeyValuesArrayToIcsAndReturnIcs,
getKeyValueIcsProperty,
setCustomKeyValueToIcsAndReturnIcs
setCustomKeyValueToIcsAndReturnIcs,
escapeICSField,
foldICSLines,
}

View File

@ -24,7 +24,7 @@
*
*/
import Vue from 'vue'
import { mapCalendarJsToCalendarObject, setClientValueToIcsAndReturnIcs, setCustomKeyValuesArrayToIcsAndReturnIcs } from '../models/calendarObject.js'
import { mapCalendarJsToCalendarObject, setClientValueToIcsAndReturnIcs, setCustomKeyValuesArrayToIcsAndReturnIcs, foldICSLines, escapeICSField } from '../models/calendarObject.js'
import logger from '../utils/logger.js'
import {
createEvent,
@ -227,6 +227,7 @@ const actions = {
let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT');
if (calendarObject.existsOnServer) {
let icsValue = calendarObject.calendarComponent.toICS();
if(eventComponent != null){
if(eventComponent.client != null){
let newClientKeyValue = "CLIENT:"+eventComponent.client;
@ -246,14 +247,18 @@ const actions = {
}
}
if(eventComponent.comment != null){
let newCommentKeyValue = "COMMENT:"+eventComponent.comment;
let regex = /COMMENT:[^\s]+/;
const escapedComment = escapeICSField(eventComponent.comment)
const foldedComment = foldICSLines(escapedComment)
let newCommentKeyValue = "COMMENT:"+foldedComment;
//let regex = /COMMENT:[^\s]+/;
let regex = /^COMMENT:.*$/m;
if(regex.test(icsValue)){
icsValue = icsValue.replace(regex, newCommentKeyValue);
}
else{
const customKeyValue = {
"COMMENT": eventComponent.comment
"COMMENT": foldedComment
};
icsValue = setCustomKeyValuesArrayToIcsAndReturnIcs(icsValue,customKeyValue);
}
@ -304,6 +309,7 @@ const actions = {
}
}
}
calendarObject.dav.data = icsValue;
await calendarObject.dav.update()
context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', {