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

modern browsers eat first newline in textarea. #69

Merged
merged 2 commits into from May 4, 2013
Merged

modern browsers eat first newline in textarea. #69

merged 2 commits into from May 4, 2013

Conversation

suvit
Copy link
Contributor

@suvit suvit commented May 4, 2013

Modern browsers eat first empty line in textarea block.
see https://code.djangoproject.com/ticket/8627

so when we parse form, we need to remove leading newline char in textarea block.

My tests broken after I started to migrate to django 1.5 branch, I use webtest to functional testing.

Also please note, that it only affects html.parser beautufulsoup builder. because in html5lib leading newline removed automaticly https://github.com/html5lib/html5lib-python/blob/master/html5lib/html5parser.py#L993.

text = node.text[1:]
else:
text = node.text
attrs['value'] = text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just do node.text.strip()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nо, we don`t want to delete last newlines chars, and the second newline from begining of the node.text. But strip removes all whitespaces (space, tab, \b) from start and end of the string

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.text.lstrip('\r\n') then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this removes \r\r\r\r\r\r\r or \r\n\r\n\r\n\r\n or \n\n\n\n\n\n\n\n or \n\r\r\r\r\r\n\r\n\r

@domenkozar
Copy link
Member

Could you add a changelog entry? Thanks!

@suvit
Copy link
Contributor Author

suvit commented May 4, 2013

I added

domenkozar added a commit that referenced this pull request May 4, 2013
modern browsers eat first newline in textarea.
@domenkozar domenkozar merged commit 8377fdf into Pylons:master May 4, 2013
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

Successfully merging this pull request may close these issues.

None yet

3 participants