Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-22 21:55:19

minusf
Member
Registered: 2005-02-15
Posts: 104

dos line ending vs unix line ending in generated html

hi there,

i was wondering what is the rationale behind the decision to generate
dos line endings in the generated html.

any decent text editor handles unix line endings fine
(if someone wants to edit the generated html that is),
and just think of all the saved bytes we wouldn’t send.

i don’t think i know any other application that does this btw
and i don’t see any reason to do this at all.

the word superfluous comes to my mind…
and yes, also unprofessional :P


we is experts™

Offline

#2 2007-07-22 22:12:06

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: dos line ending vs unix line ending in generated html

I suspect the only DOS/Windows line endings you’ll see are the ones you supply yourself in textareas. As far as I can see Textpattern itself only adds Unix style line endings.

Doesn’t matter much though, because if you care about saving bytes, you’re using gzip compression on HTML output and the \r\n will compress just as good as \n.

Offline

#3 2007-07-22 23:02:52

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: dos line ending vs unix line ending in generated html

I suspect the only DOS/Windows line endings you’ll see are the ones you supply yourself in textareas. As far as I can see Textpattern itself only adds Unix style line endings.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"^M
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">^M
<html xmlns="http://www.w3.org/1999/xhtml">^M
<head>^M

Doesn’t matter much though, because if you care about saving bytes, you’re using gzip compression on HTML output and the \r\n will compress just as good as \n.

you said it yourself: “if”. not everyone is using it.
and saving bytes is just seconday, althought the littles add up in the end.

i would really like to see a “proper” argument. i am sorry but this is not.


we is experts™

Offline

#4 2007-07-23 01:09:36

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: dos line ending vs unix line ending in generated html

That is not generated by Textpattern, that is from page templates, which you can change yourself. As to why the defaults use carriage returns in addition to line feeds, I do not know, neither does Ruud. They have been there since the beginning, long before Ruud or I showed up. Maybe there is a reason for them, maybe there isn’t. You’d have to ask Dean, whom is long-since vanished, or see if maybe Sencer or Robert knows if there’s a reason for them.

Offline

#5 2007-07-23 09:41:30

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: dos line ending vs unix line ending in generated html

i have looked at the db dump, the templates are definitely saved
having \r\n… forms also have \r\n, but article content does not.
the plugins i use do not either.

i can’t recall if textareas send \r\n or \n (my guess is \n only)
but, either way, one of these is modified inside txp to add/remove stuff…

i’d send a patch, but i am at work, and someone who knows the code
can find this much faster…


we is experts™

Offline

#6 2007-07-28 12:19:17

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: dos line ending vs unix line ending in generated html

hello everyone,

i think i have an idea what is happening.
i looked for all the \r’s in the txp source and they don’t seem to be
added anywhere, rather removed in some cases. so how come they
are in every form, every page?

because the initial sql dump contains it. notice that one cannot create
a new ‘page’, only modify and/or copy existing ones under
different names… it’s been with us all this time..

here’s a patch against 4.0.5

(all the other lines are only whitespace fixes)


we is experts™

Offline

#7 2007-07-28 12:24:18

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: dos line ending vs unix line ending in generated html

and what about all the existing pages?

i think it would be nice to add stripping before saving any ‘page’ in
include/txp_page.php:page_save().


we is experts™

Offline

#8 2007-07-28 12:36:10

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: dos line ending vs unix line ending in generated html

When submitting a form containing a textarea, the line endings used depend on the operating system and browser that submits the textarea. From what I’ve read, there’s a preference for CRLF above LF, but XHTML parsers should normalize line endings before parsing anyway so it doesn’t really matter what is used and if line ending styles are mixed.

Offline

#9 2007-07-28 12:47:31

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: dos line ending vs unix line ending in generated html

if it doesn’t matter, then surely it won’t hurt to make sure, would it?

less is more after all. why make it bigger, longer?
think of all the thousands of txp sites out there sending one
extra byte for almost every single line on every single page
for no valid reason whatsoever.

also leaving such matters to clients is never a good idea,
i am sure many web developers would agree…

and finally, i am quite sure my firefox on openbsd would
not send \r\n textareas if it didn’t get one in the first place…
it is returning data in the format it got it in…

frankly, i don’t see why you resist this no-brainer change
so much. we are wasting each other’s time here…

Last edited by minusf (2007-07-28 12:56:36)


we is experts™

Offline

#10 2007-07-28 13:01:11

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: dos line ending vs unix line ending in generated html

Oh, I don’t mind stripping \r from the default forms/pages/styles. It’s just that I don’t think it solves anything. We’d have to normalize line endings for each textarea that is submitted to accomplish what you suggest. And the question for every change is: why is that needed?
The answer to that question, like I said before, is not size reduction, because people worried about size are using compression and in that case the size difference is negligible (if there is any at all).

So, I’m curious why this is so important to you? Changes should happen for the right reasons.

Offline

#11 2007-07-28 16:45:13

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: dos line ending vs unix line ending in generated html

the new forms i have created do not have these.
so yes, i am quite sure this “will go away” just by changing it at the root.

it is important for me, because i don’t like redundant things
which are absolutely useless, without a purpose and even
take up space. call me a minimalist, i am not ashamed of it.

removing \r from the install sql dump is trivial even to be trivial.
it’s a free lunch. it shouldn’t have been there in the first place.
if you want to ask a question, ask “why was it there in the first place”
and not “why change it now”…

i started using txp because i saw that it cares about the
small details. this is such a small detail.


we is experts™

Offline

#12 2007-07-28 17:26:18

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: dos line ending vs unix line ending in generated html

Okay, see changeset 2513

This probably doesn’t prevent people on Windows systems from submitting stuff with CRLF linebreaks, but at least you start out with the same style line breaks everywhere (in most other places we were already using Unix style line breaks).

Last edited by ruud (2007-07-28 17:30:39)

Offline

Board footer

Powered by FluxBB