Author Topic: [SOLVED] proposed fix for mylivecd  (Read 832 times)

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
[SOLVED] proposed fix for mylivecd
« on: April 19, 2011, 05:22:40 AM »
Hi All,

looking at this thread: http://www.pclinuxos.com/forum/index.php/topic,89932
it appears that some filenames, containing some special characters, i.e. "(" and "&" , is actually affecting the behavior of mylivecd.

I do believe that mylivecd, as a backup tool, should be unaffected by any filenames a user may create, and that the script must be fixed, it look like the problems is that the filename is actually used inside a perl expression, and that in the end the expression is affected from the special characters that may be used in the filenames. The solution is to "escaping" "quote" the filename strings, so that when evaluated inside the expression, it's threated as a strings unit and not as a subexpression.

Problem look like to be in line 301 of mylivecd script:
Code: [Select]
               if (!defined($progress_text) || !($text =~ m/^$progress_text$/)) {
my proposasl is about to change this line as follow:
Code: [Select]
               if (!defined($progress_text) || !($text =~ m/^(\Q$progress_text\E)$/)) {

reference:
http://perldoc.perl.org/functions/quotemeta.html

I'm absolutely not a perl programmer, therefore I ask that my guess could be verified by someone more expert.

AS
« Last Edit: April 25, 2011, 03:49:53 AM by as »

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3990
Re: proposed fix for mylivecd
« Reply #1 on: April 19, 2011, 07:24:16 AM »
Why not just:
Code: [Select]

 if (!defined($progress_text) || ($text ne $progress_text)) {

The context doesn't appear to need a regular expression match - just an equality check - and REs are resource-expensive.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: proposed fix for mylivecd
« Reply #2 on: April 25, 2011, 03:49:35 AM »
Why not just:
Code: [Select]

 if (!defined($progress_text) || ($text ne $progress_text)) {

The context doesn't appear to need a regular expression match - just an equality check - and REs are resource-expensive.


Thank you kjpetrie,

just seen the fix you proposed found it's way in the latest mylivecd update!  :)

Thank you Texstar!

AS