rejetto forum

Possible bug in %folder-resource% function

artur · 16 · 7196

0 Members and 1 Guest are viewing this topic.

Offline artur

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Hi,

at first I would like to thank you rejetto for your great work with hfs. And sorry for my bad English, but I hope you will understand me ;)

Now, I think I have found bug in %folder-resource% function. Lets say I have added real folder from hard drive (C:\folder) to vfs (http://localhost/folder/). When I open that folder using web browser, function works perfectly and returns "C:\folder". But if I add/create another folder named new (C:\folder\new) and I open that folder by web broswer (http://localhost/folder/new) function will return "C:\folder ew" (should be C:\folder\new). \n disappears. I'm using HFS 2.3 beta (build 253).

And one more thing. My HFS is "behind" Apache (HFS is running on port 81, Apache on 80). I'm using VirtualHost with reverse_proxy mod and it works perfectly, except one thing: HFS logs only IP address of PC that he is running at (I see in log 2010-02-03 23:41:57 192.168.1.202:2565 Requested GET /, and IP address of server in local network is 192.168.1.202). I'm using {.add to log |{.header|X-Forwarded-For.}.} to see incoming ip's, but it makes log hard to read. Is it possible to modify log and for example give choice what IP should logged (that from request or that stored in header in X-Forwarded-For)?

Thank you,
Artur.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
Now, I think I have found bug in %folder-resource% function. Lets say I have added real folder from hard drive (C:\folder) to vfs (http://localhost/folder/). When I open that folder using web browser, function works perfectly and returns "C:\folder". But if I add/create another folder named new (C:\folder\new) and I open that folder by web broswer (http://localhost/folder/new) function will return "C:\folder ew" (should be C:\folder\new). \n disappears. I'm using HFS 2.3 beta (build 253).

to obtain more information about, can you doing the same test by using \view instead of \new , it is to know if the \n is replaced in internal by a CRLF

thanks for reporting ;)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
i have doing this test

c:\
   |- folder
       |- new
       |- view

folder added to the vfs as real

in to properties : diff template inersted  %folder-resource%

results are for /folder  ,  /folder/new   and    /folder/view

Quote
C:\folder

C:\folder\
ew

C:\folder\view

confimed:   \n is replaced by a CRLF

%folder-ressource% seem defined correctly , but between the moment, he is replaced by the resource and the web result, there is a HIC  :D

« Last Edit: February 04, 2010, 10:28:20 AM by Mars »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Found why: the bug come from here

Quote
 result:=xtpl(result, [
    '\n', CRLF,
    '%build-time%', floatToStrF((now()-buildTime)*SECONDS, ffFixed, 7,3)
  ]);

i see no solution, exept removing the red line

adding a space after \n is doing another bug with  "c:\folder\n ew-york"  :-[


result:=xtpl(result, [
    '\n', CRLF,
 must be applicated only when and where it is necessary , and not on the full result ;)

one solution is given at this post
http://www.rejetto.com/forum/index.php/topic,8173.msg1048477.html#msg1048477

« Last Edit: February 04, 2010, 10:02:10 PM by Mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
well,
what i don't understand is how this has never been reported before.
the "\n" characters sequence is translated to a newline, because this could be handy, but this way it has more cons than pros.
i will remove this thing for next release (254), and i just hope this won't cause incompatibilities with who used this feature till now.
is anyone aware of current usage of this feature? the default template doesn't use it.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile

Offline r][m

  • Tireless poster
  • ****
    • Posts: 347
    • View Profile
well,
what i don't understand is how this has never been reported before.
the "\n" characters sequence is translated to a newline, because this could be handy, but this way it has more cons than pros.
i will remove this thing for next release (254), and i just hope this won't cause incompatibilities with who used this feature till now.
is anyone aware of current usage of this feature? the default template doesn't use it.
I use it in Events to start a new line in 4 special logs, as text files. Could there be another way
that I could cause them to start a new line?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
I use it in Events to start a new line in 4 special logs, as text files. Could there be another way that I could cause them to start a new line?

just hit your ENTER key, in place of it, and that should be enough.
if you can't solve this way, post your script and we'll help you.


Offline artur

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
I see you have found solution for \n problem. Nice job Mars and rejetto! I found that accidentally, when because of it I couldn't load files to textarea's in some folders.

But you didn't answered to my second question. I was looking for solution for some time, but found nothing. Is it possible to log IP not only from request, but also from header of that request (X-Forwarded-For). Or maybe there is another way to configure HFS with Apache and give HFS possibility to log right IP?


Offline r][m

  • Tireless poster
  • ****
    • Posts: 347
    • View Profile
just hit your ENTER key, in place of it, and that should be enough.
if you can't solve this way, post your script and we'll help you.
Events
Code: [Select]
[file deleted]
\n{.append|/Server/Admin/log_file/Deleted-List.txt|Deleted ; %item-deleted% ; %date% %time% ; %user% ;
.}\n
Would the fix even affect the way I'm using "\n" ?
« Last Edit: February 08, 2010, 05:07:36 PM by r][m »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
yes, it will
you should replace the \n with a real "newline".
better do it now.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
But you didn't answered to my second question. I was looking for solution for some time, but found nothing. Is it possible to log IP not only from request, but also from header of that request (X-Forwarded-For). Or maybe there is another way to configure HFS with Apache and give HFS possibility to log right IP?

HFS 2.3 supports the x-forwarded-for field.
since the proxy needs to be trusted, by default HFS allows this field just for 127.0.0.1 (localhost).
if your proxy (apache?) is on another machine, you need to edit hfs.ini where the line starts by "forwarded-mask".
a simple way to do this is to run this simple script (menu > debug > run script)
{.set ini|forwarded-mask=127.0.0.1;192.168.* .}
« Last Edit: February 09, 2010, 12:53:57 AM by rejetto »


Offline r][m

  • Tireless poster
  • ****
    • Posts: 347
    • View Profile
yes, it will
you should replace the \n with a real "newline".
better do it now.
Google really didn't show me much.
What is a "real newline" that works for Notepad to replace \n ?
« Last Edit: February 09, 2010, 06:57:32 AM by r][m »


Offline artur

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Thank you rejetto, works fine. I have to say, you give great support to your program. Nice job!