This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 187143 - ftp upload of PHP script or other text files creates control M or char(13) characters when uploaded to UNIX or LINUX target
Summary: ftp upload of PHP script or other text files creates control M or char(13) ch...
Status: REOPENED
Alias: None
Product: php
Classification: Unclassified
Component: FTP Support (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-03 14:03 UTC by fcastro7
Modified: 2011-06-13 09:27 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
PHP file (5.16 KB, text/plain)
2010-06-03 14:03 UTC, fcastro7
Details
php-File with shebang and Windows line-endings (58 bytes, text/plain)
2010-09-14 12:24 UTC, JerryWho
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fcastro7 2010-06-03 14:03:16 UTC
When a PHP, HTML, CSS, or JavaScript text file is uploaded using NetBeans FTP, the files created on the target UNIX or LINUX box have one or more Control M characters at end of line.  The character is a char(13) or \r or /\cM/.

This prevents the PHP or JavaScript from running.  Also, if the characters are in the CSS file, the HTML does not cisplay correctly.

Attached is an example of a "corrupted" file.
Comment 1 fcastro7 2010-06-03 14:03:55 UTC
Created attachment 99789 [details]
PHP file
Comment 2 Tomas Mysik 2010-06-04 06:32:42 UTC
Well, NetBeans transfers all files using BINARY mode. I would create perhaps a new PHP Options panel (in Tools > Options > PHP) where one could specify which file extensions should be transfered in ASCII mode (candidates are php, phtml, js, css, html).

Any objections?
Comment 3 Tomas Mysik 2010-06-04 06:34:22 UTC
BTW it means that the settings will be common for all the PHP projects - maybe we could create such panel for every PHP project so one can specify different file extensions for different PHP projects.

Would this makes sense?
Comment 4 Filip Zamboj 2010-06-04 15:38:55 UTC
(In reply to comment #3)
> BTW it means that the settings will be common for all the PHP projects - maybe
> we could create such panel for every PHP project so one can specify different
> file extensions for different PHP projects.
> 
> Would this makes sense?
would make sense IMO 

(trying to reproduce but having troubles after ubuntu upgrade :(( )
Comment 5 Tomas Mysik 2010-06-04 15:45:44 UTC
(In reply to comment #4)
> (trying to reproduce but having troubles after ubuntu upgrade :(( )

Before any changes, we need to be sure that it is really broken otherwise there won't be any benefit from the change; so please, try to reproduce, I will try as well (on Monday).

Thanks.
Comment 6 Filip Zamboj 2010-06-04 15:57:26 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > (trying to reproduce but having troubles after ubuntu upgrade :(( )
> 
> Before any changes, we need to be sure that it is really broken otherwise there
> won't be any benefit from the change; so please, try to reproduce, I will try
> as well (on Monday).
> 
> Thanks.

understood.
Comment 7 Filip Zamboj 2010-06-07 11:07:00 UTC
Product Version: NetBeans IDE Dev (Build 2010-06-06_03-03-36 )
Java: 1.6.0_14-ea; Java HotSpot(TM) Client VM 14.0-b12
System: Windows Vista version 6.0 running on x86; Cp1250; cs_CZ (nb)
Userdir: C:\Users\felipee\.netbeans\dev

I cannot reproduce reported problem. 
Configuration: 
source: WIN Vista 
Target: Ubuntu - Karmic Koala

Files with windows endings were successfully run and uploaded from WIN to LIN. There was no problem with files endings. I'd say it's a problem in ftp configuration of reporter's target server. I doubt apache can't parse files with windows endings when running on linux machine and I didn't find any unusual netbeans ftp client behaviour. 

I'm closing as worksforme. However, reporter, could you upload file that becomes corrupted on server (in some compressed form)? Thanks a lot.
Comment 8 JerryWho 2010-09-14 12:24:14 UTC
Created attachment 102010 [details]
php-File with shebang and Windows line-endings

The attached file gives the following error on a linux machine when invoked (as a shell skript): 

> ./test.php
-bash: ./test.php: /usr/local/bin/php^M: bad interpreter: Datei oder Verzeichnis nicht gefunden

As you can see it's relevant to change line endings via ftp. Therefor I would like to reopen the bug.
Comment 9 Filip Zamboj 2010-09-15 12:37:39 UTC
batch reassigning
Comment 10 Tomas Mysik 2011-06-03 10:18:47 UTC
Batch reassigning.
Comment 11 Tomas Mysik 2011-06-10 06:34:29 UTC
(In reply to comment #8)
> > ./test.php
> -bash: ./test.php: /usr/local/bin/php^M: bad interpreter: Datei oder
> Verzeichnis nicht gefunden
> 
> As you can see it's relevant to change line endings via ftp. Therefor I would
> like to reopen the bug.

Well, not exactly - this is not a problem of a PHP script, it is a problem of shell interpreter (I mean that php-cli would run this file without any error, the problem is that operating system cannot find the interpreter); anyway, if NetBeans would change line endings, it would cause more serious errors (for all binary files like ZIP, PDF, images etc.).

BTW in your particular case, the error is already in your file on your computer and it is likely caused by the changed line-ending (at least I guess so since the file was likely created on *nix or is definitely supposed to run on it but contains Windows line-ending, moreover in the line where the shell interpreter is defined).

So, I don't think we should change the current behavior (the same from NetBeans 6.5), feel free to reopen if you disagree.

Thanks for reporting.
Comment 12 JerryWho 2011-06-10 15:30:08 UTC
Yes, you can blame the different line endings for the error they are causing. But I think the solution exists in the ftp-protocol: There is the posibility to switch between binary and ascii mode. The first one won't change anything in the transferred file. So this would be the correct mode for images and so on.

The latter mode will change line endings so you can use always the native line endings on both sides of the transfer.

So my preferred solution would contain the possibility to choose file-extensions which are transfered in ascii mode (such as .php, .sh, .css, .html, ...). Any other files are transferred in binary mode. That's the behaviour of any traditional ftp-client. E.g. filezilla: http://filezilla-project.org/images/screenshots/fz3_win_settings.png Transfer->File types.
Comment 13 Tomas Mysik 2011-06-13 09:27:09 UTC
Agreed, however adding configuration for FTP transfer modes is more enhancement than a bug.