Askozia Forums
May 21, 2012, 09:10:28 pm
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Search
Login
Register
Askozia Forums
>
AskoziaPBX
>
Bug Reports
>
r422 diag_editor appends characters
Pages: [
1
]
« previous
next »
Print
Author
Topic: r422 diag_editor appends characters (Read 666 times)
devon
Guest
r422 diag_editor appends characters
«
on:
February 24, 2008, 03:24:58 am »
To reproduce this, go to diag_exec.php and execute the following command to create a two-line file called 'test'.
# echo "foo1" > /etc/test && echo "foo2" >> test
Download and view the resulting file '/etc/test' in hex:
000000: 66 6f 6f 31
0a
66 6f 6f 32
0a
|foo1.foo2.|
Now go to diag_editor.php and open /etc/test. Don't make any changes, just click 'Save'.
Download and view the saved file '/etc/test' in hex:
000000: 66 6f 6f 31
0d 0a
66 6f 6f 32
0d 0a
|foo1..foo2..|
I know the 'diag' pages are unsupported but I just wanted to let those who use the editor for testing purposes know that some programs (cron sees ^M) don't know how to handle files edited this way, and may do strange things.
Logged
devon
Guest
Re: r422 diag_editor appends characters
«
Reply #1 on:
February 24, 2008, 07:16:40 am »
Well, it turns out that this is just a result of 'file_get_contents' adding \r\n linefeeds. One way I found to fix this in diag_editor.php is to use 'str_replace' (shown in red) to remove the unwanted "\r" linefeeds.
<-snip->
} else if (isset($pconfig['save'])) {
conf_mount_rw();
$f = fopen($pconfig['file'], "w");
$pconfig['contents'] = str_replace("\r", "", $pconfig['contents']);
fwrite($f, $pconfig['contents']);
fclose($f);
conf_mount_ro();
$savemsg = "File contents ({$pconfig['file']}) saved.";
}
<-snip->
In this example, the 'conf_mount' functions (in green) would allow configuration files in /conf to be edited and saved.
Logged
Michael
Askozia Staff
Hero Member
Karma: 49
Posts: 1020
Re: r422 diag_editor appends characters
«
Reply #2 on:
February 24, 2008, 06:43:41 pm »
Nice find. I've committed your changes with a small modification here:
-
http://lists.askozia.com/pbx-commits/showmsg.php?id=0/47
Thanks!
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> Announcements
=> Events
=> Meta
-----------------------------
AskoziaPBX
-----------------------------
=> General
=> Call Flow Editor
=> Handbook
=> Installation
=> Hardware
===> For Sale / Wanted
=> Interface Configuration
=> Provider Accounts
=> Phone Accounts
=> Dialplan
===> Applications
=> Packages
=> Bug Reports
=> Feature Requests
=> Development
===> Bounties
=> Internationalization
-----------------------------
International
-----------------------------
=> Nederlands
=> 普通話
=> Deutsch
=> Español
=> Français
=> Italiano
=> 日本語
=> Português
=> Русский язык
Loading...