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

Conversation

Projects
None yet
3 participants
@suvit
Contributor

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

This comment has been minimized.

@domenkozar

domenkozar May 4, 2013

Member

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

@domenkozar

domenkozar May 4, 2013

Member

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

This comment has been minimized.

@suvit

suvit May 4, 2013

Contributor

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

@suvit

suvit May 4, 2013

Contributor

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

This comment has been minimized.

@gawel

gawel May 5, 2013

Member

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

@gawel

gawel May 5, 2013

Member

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

This comment has been minimized.

@suvit

suvit May 5, 2013

Contributor

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

@suvit

suvit May 5, 2013

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@domenkozar

domenkozar May 4, 2013

Member

Could you add a changelog entry? Thanks!

Member

domenkozar commented May 4, 2013

Could you add a changelog entry? Thanks!

@suvit

This comment has been minimized.

Show comment
Hide comment
@suvit

suvit May 4, 2013

Contributor

I added

Contributor

suvit commented May 4, 2013

I added

domenkozar added a commit that referenced this pull request May 4, 2013

Merge pull request #69 from suvit/master
modern browsers eat first newline in textarea.

@domenkozar domenkozar merged commit 8377fdf into Pylons:master May 4, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment