Skip to content

Commit aaed338

Browse files
committed
updated
1 parent f022c66 commit aaed338

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

apps/sim/app/api/tools/confluence/page-properties/route.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ export async function PUT(request: NextRequest) {
238238
return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
239239
}
240240

241+
const propertyIdValidation = validateAlphanumericId(propertyId, 'propertyId', 255)
242+
if (!propertyIdValidation.isValid) {
243+
return NextResponse.json({ error: propertyIdValidation.error }, { status: 400 })
244+
}
245+
241246
const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
242247

243248
const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
@@ -315,6 +320,11 @@ export async function DELETE(request: NextRequest) {
315320
return NextResponse.json({ error: pageIdValidation.error }, { status: 400 })
316321
}
317322

323+
const propertyIdValidation = validateAlphanumericId(propertyId, 'propertyId', 255)
324+
if (!propertyIdValidation.isValid) {
325+
return NextResponse.json({ error: propertyIdValidation.error }, { status: 400 })
326+
}
327+
318328
const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
319329

320330
const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')

apps/sim/app/api/tools/confluence/pages/route.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ export async function POST(request: NextRequest) {
3232
return NextResponse.json({ error: 'Access token is required' }, { status: 400 })
3333
}
3434

35-
// Use provided cloudId or fetch it if not provided
3635
const cloudId = providedCloudId || (await getConfluenceCloudId(domain, accessToken))
3736

3837
const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
3938
if (!cloudIdValidation.isValid) {
4039
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
4140
}
4241

43-
// Build the URL with query parameters
4442
const baseUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages`
4543
const queryParams = new URLSearchParams()
4644

@@ -57,7 +55,6 @@ export async function POST(request: NextRequest) {
5755

5856
logger.info(`Fetching Confluence pages from: ${url}`)
5957

60-
// Make the request to Confluence API with OAuth Bearer token
6158
const response = await fetch(url, {
6259
method: 'GET',
6360
headers: {
@@ -79,7 +76,6 @@ export async function POST(request: NextRequest) {
7976
} catch (e) {
8077
logger.error('Could not parse error response as JSON:', e)
8178

82-
// Try to get the response text for more context
8379
try {
8480
const text = await response.text()
8581
logger.error('Response text:', text)

apps/sim/app/api/tools/confluence/search-in-space/route.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ export async function POST(request: NextRequest) {
5353
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
5454
}
5555

56-
// Build CQL query
57-
let cql = `space = "${spaceKey}"`
56+
const escapeCqlValue = (value: string) => value.replace(/"/g, '\\"')
57+
58+
let cql = `space = "${escapeCqlValue(spaceKey)}"`
5859

5960
if (query) {
60-
cql += ` AND text ~ "${query}"`
61+
cql += ` AND text ~ "${escapeCqlValue(query)}"`
6162
}
6263

6364
if (contentType) {
64-
cql += ` AND type = "${contentType}"`
65+
cql += ` AND type = "${escapeCqlValue(contentType)}"`
6566
}
6667

6768
const searchParams = new URLSearchParams({

apps/sim/app/api/tools/confluence/search/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ export async function POST(request: NextRequest) {
4242
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
4343
}
4444

45+
const escapeCqlValue = (value: string) => value.replace(/"/g, '\\"')
46+
4547
const searchParams = new URLSearchParams({
46-
cql: `text ~ "${query}"`,
48+
cql: `text ~ "${escapeCqlValue(query)}"`,
4749
limit: limit.toString(),
4850
})
4951

0 commit comments

Comments
 (0)