Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit e78e089

Browse files
bpamiriclaude
andcommitted
fix: XSS in flash messages, hardcoded user ID, missing semicolon, dead code
- Escape flash messages with jsStringFormat() before embedding in JS string (layout.cfm:617) to prevent XSS via single quotes in flash content - Replace hardcoded updatedBy=1 with GetSignedInUserId() in blog deletion - Add missing semicolon after return in unpublishBlog() - Remove unused getAll() and no-op logBlogRequest() dead code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d3bb47a commit e78e089

2 files changed

Lines changed: 3 additions & 14 deletions

File tree

app/controllers/web/BlogController.cfc

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ component extends="app.Controllers.Controller" {
2424
isInfiniteScroll = structKeyExists(params, "infiniteScroll") ? params.infiniteScroll : false;
2525
userId = GetSignedInUserId();
2626

27-
// Log request details
28-
logBlogRequest(filterType, filterValue, page, perPage, userId);
29-
3027
try {
3128
var result = getBlogData(filterType, filterValue, page, perPage, isInfiniteScroll);
3229

@@ -63,10 +60,6 @@ component extends="app.Controllers.Controller" {
6360
return trim(arguments.param);
6461
}
6562

66-
// Helper function to log blog requests (no-op for performance; enable for debugging)
67-
private void function logBlogRequest(filterType, filterValue, page, perPage, userId) {
68-
}
69-
7063
// Main data retrieval logic
7164
private struct function getBlogData(filterType, filterValue, page, perPage, isInfiniteScroll) {
7265
var result = {};
@@ -809,10 +802,6 @@ component extends="app.Controllers.Controller" {
809802

810803
// Business Logic
811804

812-
private function getAll() {
813-
return model("Blog").findAll();
814-
}
815-
816805
private function getAllBlogs(numeric page=1, numeric perPage=6, boolean isInfiniteScroll=false) {
817806
var result = {
818807
query = model("Blog").findAll(
@@ -1029,7 +1018,7 @@ component extends="app.Controllers.Controller" {
10291018
if (not isNull(blog)) {
10301019
blog.isDeleted = true;
10311020
blog.updatedAt = now();
1032-
blog.updatedBy = 1; // Replace with logged-in user ID
1021+
blog.updatedBy = GetSignedInUserId();
10331022
blog.save();
10341023
message = "Blog post deleted successfully.";
10351024
} else {
@@ -1195,7 +1184,7 @@ component extends="app.Controllers.Controller" {
11951184

11961185
if (blog.createdBy != currentUserId AND !isUserAdmin()) {
11971186
renderText(" UnauthorizedAccess : You do not have permission to unpublish this blog");
1198-
return
1187+
return;
11991188
}
12001189

12011190
blog.publishedAt = "";

app/views/layout.cfm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@
614614
<cfoutput>
615615
<cfif flashMessages() neq "">
616616
<script>
617-
const html = '#flashMessages()#';
617+
const html = '#jsStringFormat(flashMessages())#';
618618
</script>
619619
<script src="/js/flashMessage.js"></script>
620620
</cfif>

0 commit comments

Comments
 (0)