Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line-break formatting in pull requests #90

Open
klundberg opened this issue Mar 13, 2017 · 5 comments
Open

Fix line-break formatting in pull requests #90

klundberg opened this issue Mar 13, 2017 · 5 comments

Comments

@klundberg
Copy link

klundberg commented Mar 13, 2017

I just got this PR from staticman: klundberg/klundberg.com#4


~~~I apologize if this already exists and I don't have my site properly configured, but when I set things up I didn't see anything along these lines of only allowing specific form fields to be sent.~~~

My mistake, it's seems like there was no clever spammer behavior here that can be easily prevented. The problem here that confused me appears to be that the line breaks in the message mess up formatting of the PR, which made it look like there were extra form fields added to embed some targeted spam only intended for blog owners. The message in that PR should probably fit entirely inside one markdown table cell, if that's possible to do.

Thank you!
@klundberg klundberg changed the title Add stricter input field validations Fix line-break formatting in pull requests Mar 13, 2017
@Stanko
Copy link

Stanko commented Oct 15, 2017

I can confirm this.

But it can be solved easily, when generating a table:

staticman/lib/Staticman.js

Lines 201 to 203 in ecf0386

Object.keys(fields).forEach(field => {
table.push([field, fields[field]])
})

Just remove new lines and replace them with breaks <br />.

  Object.keys(fields).forEach(field => {
    table.push([field, fields[field].replace(/\n/gm, '<br />')])
  })

Afaik this is the only way to add newlines to a markdown table.

I will do a PR for this soon.
EDIT: This is a one line fix, but I'm not sure how to test it before making a PR :/

@Stanko
Copy link

Stanko commented Mar 2, 2018

Bump, any news on this one?

@JokerQyou
Copy link

JokerQyou commented Mar 9, 2018

Just got two comments with the same issue, and each of them renders differently. One looks exactly same like the PR in @klundberg 's repo. And the other look like this:

image

Furthermore, I don't understand where the fields tags and layout came from. I've never configured them in allowedFields in staticman.yml.

@BloggerBust-bot
Copy link

@JokerQyou The code is only replacing LF, but I suspect your example had CR/LF. In PR #289 I chained two calls to replace to handle both scenarios.

@VincentTam
Copy link
Contributor

@BloggerBust-bot Your PR contains an unnecessary dependence on #285, so I created another one for the convenience of v3 users. Anyways, great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants