From: "C.E. Thornton" Date: 2008-07-19T05:27:23+09:00 Subject: [ruby-core:17842] Patch for expand_path fix --- This is a multi-part message in MIME format. --------------030108040308000200000100 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Core, Enclosed is a patch to correct "expand_path" error. (See previous messages) The Results of tst.rb testing are: hydra(Wpad02}$tst.rb ruby 1.8.7 (2008-05-31 patchlevel 0) [x86_64-linux] Dir = /home/thornton/WorkPads/Wpad02/~test Dir = /home/thornton/WorkPads/Wpad02/t~st Dir = /home/thornton/WorkPads Dir = /home/thornton/WorkPads/Wpad02/ATTIC Dir = /home/thornton/WorkPads/Wpad02/test Dir = /home/thornton/WorkPads/Wpad02 hydra(Wpad02}$tst.rb w ruby 1.8.7 (2008-05-31 patchlevel 0) [x86_64-linux] Dir = /home/thornton/WorkPads/Wpad02/~test Dir = /home/thornton/WorkPads/Wpad02/t~st Dir = /home/thornton/WorkPads/Wpad02/.. Dir = /home/thornton/WorkPads/Wpad02/ATTIC Dir = /home/thornton/WorkPads/Wpad02/test Dir = /home/thornton/WorkPads/Wpad02/. This patch changes the processing when a '~' tilde char is detected. It will only follow the old path IF there is a tilde followed by a '/' or '\0'. This patch is the simplest. I did not remove the following test for JUST '/' and '\0'. Leaving them in place does no harm. I matz agrees with this fix and want's it to be cleaner patch, I will produce it. I have tested this on CENTOS 4.6 System. BUT I have no idea how it will work on other platforms. I assume that the tilde is a linux/unix "thing" not XP or VISTA (ugh!) Chuck T. -- Competency and chastity have much in common, they both encompass their own punishment! -- C.E. Thornton -- Hawthorne Press -- --------------030108040308000200000100 Content-Type: text/plain; name="file_expand_patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="file_expand_patch" --- file.c 2008-07-18 14:50:11.000000000 -0500 +++ file.c_new 2008-07-18 15:03:18.000000000 -0500 @@ -2530,7 +2530,7 @@ BUFINIT(); tainted = OBJ_TAINTED(fname); - if (s[0] == '~') { + if (s[0] == '~' && (isdirsep(s[1]) || s[1] == '\0')) { if (isdirsep(s[1]) || s[1] == '\0') { char *dir = getenv("HOME"); --------------030108040308000200000100--