Skip to content

Commit dcd757c

Browse files
Merge pull request #14630 from nextcloud/backport/14629/stable31
[stable31] fix(calls): Fix displayname when exporting call participants
2 parents 39d973d + 0073132 commit dcd757c

File tree

6 files changed

+19
-32
lines changed

6 files changed

+19
-32
lines changed

lib/Controller/CallController.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public function getPeersForCall(): DataResponse {
121121
*
122122
* Required capability: `download-call-participants`
123123
*
124-
* @param 'csv'|'pdf' $format Download format
125-
* @return DataDownloadResponse<Http::STATUS_OK, 'text/csv'|'application/pdf', array{}>|Response<Http::STATUS_BAD_REQUEST, array{}>
124+
* @param 'csv' $format Download format
125+
* @return DataDownloadResponse<Http::STATUS_OK, 'text/csv', array{}>|Response<Http::STATUS_BAD_REQUEST, array{}>
126126
*
127127
* 200: List of participants in the call downloaded in the requested format
128128
* 400: No call in progress
@@ -141,13 +141,8 @@ public function downloadParticipantsForCall(string $format = 'csv'): DataDownloa
141141
return new Response(Http::STATUS_BAD_REQUEST);
142142
}
143143

144-
if ($format !== 'csv' && $format !== 'pdf') {
145-
// Unsupported format
146-
return new Response(Http::STATUS_BAD_REQUEST);
147-
}
148-
149144
if ($format !== 'csv') {
150-
// FIXME Remove once pdf was implemented.
145+
// Unsupported format
151146
return new Response(Http::STATUS_BAD_REQUEST);
152147
}
153148

@@ -166,12 +161,12 @@ public function downloadParticipantsForCall(string $format = 'csv'): DataDownloa
166161
} elseif ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
167162
$email = $this->userManager->get($participant->getAttendee()->getActorId())?->getEMailAddress() ?? '';
168163
}
169-
fputcsv($output, [
164+
fputcsv($output, array_map([$this, 'escapeFormulae'], [
170165
$participant->getAttendee()->getDisplayName(),
171166
$email,
172167
$participant->getAttendee()->getActorType(),
173168
$participant->getAttendee()->getActorId(),
174-
], escape: '');
169+
]), escape: '');
175170
}
176171

177172
fseek($output, 0);
@@ -198,6 +193,13 @@ public function downloadParticipantsForCall(string $format = 'csv'): DataDownloa
198193
return new DataDownloadResponse(stream_get_contents($output), $fileName, 'text/csv');
199194
}
200195

196+
protected function escapeFormulae(string $value): string {
197+
if (preg_match('/^[=+\-@\t\r]/', $value)) {
198+
return "'" . $value;
199+
}
200+
return $value;
201+
}
202+
201203
/**
202204
* Join a call
203205
*

openapi-full.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -4785,8 +4785,7 @@
47854785
"type": "string",
47864786
"default": "csv",
47874787
"enum": [
4788-
"csv",
4789-
"pdf"
4788+
"csv"
47904789
]
47914790
}
47924791
},
@@ -4810,12 +4809,6 @@
48104809
"type": "string",
48114810
"format": "binary"
48124811
}
4813-
},
4814-
"application/pdf": {
4815-
"schema": {
4816-
"type": "string",
4817-
"format": "binary"
4818-
}
48194812
}
48204813
}
48214814
},

openapi.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -4690,8 +4690,7 @@
46904690
"type": "string",
46914691
"default": "csv",
46924692
"enum": [
4693-
"csv",
4694-
"pdf"
4693+
"csv"
46954694
]
46964695
}
46974696
},
@@ -4715,12 +4714,6 @@
47154714
"type": "string",
47164715
"format": "binary"
47174716
}
4718-
},
4719-
"application/pdf": {
4720-
"schema": {
4721-
"type": "string",
4722-
"format": "binary"
4723-
}
47244717
}
47254718
}
47264719
},

src/types/openapi/openapi-full.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3660,7 +3660,7 @@ export interface operations {
36603660
parameters: {
36613661
query?: {
36623662
/** @description Download format */
3663-
format?: "csv" | "pdf";
3663+
format?: "csv";
36643664
};
36653665
header: {
36663666
/** @description Required to be true for the API request to pass */
@@ -3681,7 +3681,6 @@ export interface operations {
36813681
};
36823682
content: {
36833683
"text/csv": string;
3684-
"application/pdf": string;
36853684
};
36863685
};
36873686
/** @description No call in progress */

src/types/openapi/openapi.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3142,7 +3142,7 @@ export interface operations {
31423142
parameters: {
31433143
query?: {
31443144
/** @description Download format */
3145-
format?: "csv" | "pdf";
3145+
format?: "csv";
31463146
};
31473147
header: {
31483148
/** @description Required to be true for the API request to pass */
@@ -3163,7 +3163,6 @@ export interface operations {
31633163
};
31643164
content: {
31653165
"text/csv": string;
3166-
"application/pdf": string;
31673166
};
31683167
};
31693168
/** @description No call in progress */

tests/integration/features/callapi/public.feature

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,18 @@ Feature: callapi/public
9595
And user "guest" joins call "room" with 200 (v4)
9696
Then user "participant1" sees 2 peers in call "room" with 200 (v4)
9797
And user "guest" sees 2 peers in call "room" with 200 (v4)
98+
And guest "guest" sets name to "=1+1" in room "room" with 200 (v1)
9899
And invoking occ with "user:setting participant1 settings email [email protected]"
99100
And user "participant2" downloads call participants from "room" as "csv" with 403 (v4)
100101
And user "participant1" downloads call participants from "room" as "csv" with 200 (v4)
101102
| name | email | type | identifier |
102103
| participant1-displayname | participant1@example.tld | users | participant1 |
103-
| | | guests | guest1 |
104+
| '=1+1 | | guests | guest1 |
104105
Then user "guest" leaves call "room" with 200 (v4)
105106
And user "participant1" downloads call participants from "room" as "csv" with 200 (v4)
106107
| name | email | type | identifier |
107108
| participant1-displayname | participant1@example.tld | users | participant1 |
108-
| | | guests | guest1 |
109+
| '=1+1 | | guests | guest1 |
109110
And invoking occ with "user:setting participant1 settings email --delete"
110111
Then user "participant1" sees 1 peers in call "room" with 200 (v4)
111112
And user "guest" sees 1 peers in call "room" with 200 (v4)

0 commit comments

Comments
 (0)