Skip to content

Commit

Permalink
trim all text from user input
Browse files Browse the repository at this point in the history
  • Loading branch information
yduman committed Sep 29, 2019
1 parent 800317d commit d3b77b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions backend/src/events/card-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ const createCard = (io, client, roomId) => {
fs.readFile(path, UTF8, (error, file) => {
if (error) logError(CREATE_CARD, error);
const board = getBoard(file);
const { author, content } = card;

card.isBlurred = board.isBlurred;
card.author = author.trim();
card.content = content.trim();

board.items[card.id] = card;
board.columns[columnId].itemIds.push(card.id);

Expand Down Expand Up @@ -61,8 +65,8 @@ const editCard = (io, client, roomId) => {
const board = getBoard(file);

const card = board.items[cardId];
card.author = author;
card.content = content;
card.author = author.trim();
card.content = content.trim();

fs.writeFile(path, stringify(board), UTF8, error => {
if (error) logError(EDIT_CARD, error);
Expand Down
4 changes: 3 additions & 1 deletion backend/src/events/column-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const createColumn = (io, client, roomId) => {
fs.readFile(path, UTF8, (error, file) => {
if (error) logError(CREATE_COLUMN, error);
const board = getBoard(file);
const { columnTitle } = column;

column.columnTitle = columnTitle.trim();
board.columns[column.id] = column;
board.columnOrder.push(column.id);

Expand Down Expand Up @@ -81,7 +83,7 @@ const editColumn = (io, client, roomId) => {
const board = getBoard(file);

const column = board.columns[columnId];
column.columnTitle = newTitle;
column.columnTitle = newTitle.trim();

fs.writeFile(path, stringify(board), UTF8, error => {
if (error) logError(EDIT_COLUMN, error);
Expand Down
2 changes: 2 additions & 0 deletions backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ app.use("/api/boards", apiRouter);

app.post("/", async (req, res) => {
const board = req.body;
const { title } = board;
board.title = title.trim();
try {
await fs.writeFile(
getPath(board.boardId),
Expand Down

0 comments on commit d3b77b7

Please sign in to comment.