mrdialog 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -363,7 +363,9 @@ class MRDialog
363
363
  # If three parameters are given, it displays the text under the
364
364
  # title, delineated from the scrolling file's contents. If only
365
365
  # two parameters are given, this text is omitted.
366
- #
366
+ # Update:
367
+ # insteaf of putting command inside single quote, use shell escape,
368
+ # otherwise if value has single quote parsing fails. Oct-18-2025
367
369
  def prgbox(command, height=0, width=0, text='')
368
370
  cmd = ""
369
371
  cmd << option_string()
@@ -371,14 +373,10 @@ class MRDialog
371
373
  cmd << "--prgbox"
372
374
  cmd << " "
373
375
  if text.length > 0
374
- cmd << "'"
375
- cmd << text
376
- cmd << "'"
376
+ cmd << Shellwords.escape(text) # Escape the text parameter
377
+ cmd << " "
377
378
  end
378
- cmd << " "
379
- cmd << "'"
380
- cmd << command
381
- cmd << "'"
379
+ cmd << Shellwords.escape(command) # Escape the command parameter
382
380
  cmd << " "
383
381
  cmd << height.to_s
384
382
  cmd << " "
@@ -397,28 +395,25 @@ class MRDialog
397
395
  #
398
396
  # On exit, the tag of the selected item is written to dialog's
399
397
  # output.
398
+ # Update:
399
+ # insteaf of putting command inside single quote, use shell escape,
400
+ # otherwise if value has single quote parsing fails. Oct-18-2025
400
401
  def treeview(text="Text Goes Here", items=nil, height=0, width=0, listheight=0)
401
402
  tmp = Tempfile.new('dialog')
402
403
  itemlist = ''
403
404
  items.each do |item|
404
- itemlist << "'"
405
- itemlist << item[0].to_s
406
- itemlist << "'"
405
+ itemlist << Shellwords.escape(item[0].to_s) # tag
407
406
  itemlist << " "
408
- itemlist << "'"
409
- itemlist << item[1].to_s
410
- itemlist << "'"
407
+ itemlist << Shellwords.escape(item[1].to_s) # text/description
411
408
  itemlist << " "
412
- itemlist << "'"
413
409
  if item[2]
414
410
  item[2] = "on"
415
411
  else
416
412
  item[2] = "off"
417
413
  end
418
- itemlist << item[2]
419
- itemlist << "'"
414
+ itemlist << item[2] # on/off status (no escaping needed)
420
415
  itemlist << " "
421
- itemlist << item[3].to_s
416
+ itemlist << item[3].to_s # depth (numeric, no escaping needed)
422
417
  itemlist << " "
423
418
  end
424
419
  itemlist << "2>"
@@ -429,10 +424,7 @@ class MRDialog
429
424
  cmd << " "
430
425
  cmd << "--treeview"
431
426
  cmd << " "
432
- cmd << "'"
433
- cmd << " "
434
- cmd << text
435
- cmd << "'"
427
+ cmd << Shellwords.escape(text) # escape the main text
436
428
  cmd << " "
437
429
  cmd << height.to_s
438
430
  cmd << " "
@@ -456,7 +448,6 @@ class MRDialog
456
448
  ensure
457
449
  tmp.close!
458
450
  end
459
-
460
451
  #
461
452
  # A buildlist dialog displays two lists, side-by-side. The list
462
453
  # on the left shows unselected items. The list on the right shows
@@ -469,7 +460,9 @@ class MRDialog
469
460
  #
470
461
  # The caller is responsile to create the items properly. Please
471
462
  # look at samples/buildlist.rb for an example.
472
- #
463
+ # Update:
464
+ # insteaf of putting command inside single quote, use shell escape,
465
+ # otherwise if value has single quote parsing fails. Oct-18-2025
473
466
  # return an array of selected tags
474
467
  # Author:: muquit@muquit.com
475
468
  def buildlist(text="Text Goes Here", items = nil, height=0, width=0, listheight=0)
@@ -478,46 +471,34 @@ class MRDialog
478
471
  itemlist = ''
479
472
 
480
473
  items.each do |item|
481
- itemlist << "'"
482
- itemlist << item[0].to_s
483
- itemlist << "'"
474
+ itemlist << Shellwords.escape(item[0].to_s) # tag
484
475
  itemlist << " "
485
- itemlist << "'"
486
- itemlist << item[1].to_s
487
- itemlist << "'"
476
+ itemlist << Shellwords.escape(item[1].to_s) # description
488
477
  itemlist << " "
489
- itemlist << "'"
490
478
  if item[2]
491
479
  item[2] = "on"
492
480
  else
493
481
  item[2] = "off"
494
482
  end
495
- itemlist << item[2]
496
- itemlist << "'"
483
+ itemlist << item[2] # on/off status (no escaping needed)
497
484
  itemlist << " "
498
485
  end
499
486
  itemlist << "2>"
500
487
  itemlist << tmp.path
501
488
 
502
489
  cmd = ""
503
-
504
490
  cmd << option_string()
505
491
  if !@separator
506
492
  @separator = "|"
507
493
  cmd << " "
508
494
  cmd << "--separator"
509
495
  cmd << " "
510
- cmd << "'"
511
- cmd << @separator
512
- cmd << "'"
496
+ cmd << Shellwords.escape(@separator) # escape separator
513
497
  end
514
498
  cmd << " "
515
499
  cmd << "--buildlist"
516
500
  cmd << " "
517
- cmd << "'"
518
- cmd << " "
519
- cmd << text
520
- cmd << "'"
501
+ cmd << Shellwords.escape(text) # escape the main text
521
502
  cmd << " "
522
503
  cmd << height.to_s
523
504
  cmd << " "
@@ -547,21 +528,21 @@ class MRDialog
547
528
  ensure
548
529
  tmp.close!
549
530
  end
550
-
551
531
  # A pause box displays a meter along the bottom of the box. The
552
532
  # meter indicates how many seconds remain until the end of the
553
533
  # pause. The pause exits when timeout is reached or the user
554
534
  # presses the OK button (status OK) or the user presses the CANCEL
555
535
  # button or Esc key.
536
+ # Update:
537
+ # insteaf of putting command inside single quote, use shell escape,
538
+ # otherwise if value has single quote parsing fails. Oct-18-2025
556
539
  def pause(text="Text Goes Here", height=0, width=0, secs=10)
557
540
  cmd = ""
558
541
  cmd << option_string()
559
542
  cmd << " "
560
543
  cmd << "--pause"
561
544
  cmd << " "
562
- cmd << "'"
563
- cmd << text
564
- cmd << "'"
545
+ cmd << Shellwords.escape(text) # escape the text parameter
565
546
  cmd << " "
566
547
  cmd << height.to_s
567
548
  cmd << " "
@@ -585,6 +566,9 @@ class MRDialog
585
566
  #
586
567
  # On exit, the contents of the edit window are written to dialog's
587
568
  # output.
569
+ # Update:
570
+ # insteaf of putting command inside single quote, use shell escape,
571
+ # otherwise if value has single quote parsing fails. Oct-18-2025
588
572
  def editbox(filepath, height=0, width=0)
589
573
  tmp = Tempfile.new('dialog')
590
574
 
@@ -593,9 +577,7 @@ class MRDialog
593
577
  cmd << " "
594
578
  cmd << "--editbox"
595
579
  cmd << " "
596
- cmd << "'"
597
- cmd << filepath
598
- cmd << "'"
580
+ cmd << Shellwords.escape(filepath) # escape the filepath
599
581
  cmd << " "
600
582
  cmd << height.to_s
601
583
  cmd << " "
@@ -617,7 +599,6 @@ class MRDialog
617
599
  ensure
618
600
  tmp.close!
619
601
  end
620
-
621
602
  #
622
603
  # form/mixedform dialog
623
604
  # A form dialog displays a form consisting of labels and fields,
@@ -630,6 +611,10 @@ class MRDialog
630
611
  # look at samples/form.rb for an example
631
612
  #
632
613
  # return a hash. keys are the labels
614
+ # Update:
615
+ # insteaf of putting command inside single quote, use shell escape,
616
+ # otherwise if value has single quote parsing fails. Oct-18-2025
617
+ #
633
618
  # Author:: muquit@muquit.com
634
619
  def form(text, items, height=0, width=0, formheight=0)
635
620
  res_hash = {}
@@ -643,28 +628,24 @@ class MRDialog
643
628
  mixed_form = true
644
629
  end
645
630
  items.each do |item|
646
- itemlist << "'"
647
- itemlist << item[0].to_s
648
- itemlist << "'"
631
+ itemlist << Shellwords.escape(item[0].to_s) # label
649
632
  itemlist << " "
650
- itemlist << item[1].to_s
633
+ itemlist << item[1].to_s # ly
651
634
  itemlist << " "
652
- itemlist << item[2].to_s
635
+ itemlist << item[2].to_s # lx
653
636
  itemlist << " "
654
- itemlist << "'"
655
- itemlist << item[3].to_s
656
- itemlist << "'"
637
+ itemlist << Shellwords.escape(item[3].to_s) # value
657
638
  itemlist << " "
658
- itemlist << item[4].to_s
639
+ itemlist << item[4].to_s # iy
659
640
  itemlist << " "
660
- itemlist << item[5].to_s
641
+ itemlist << item[5].to_s # ix
661
642
  itemlist << " "
662
- itemlist << item[6].to_s
643
+ itemlist << item[6].to_s # flen
663
644
  itemlist << " "
664
- itemlist << item[7].to_s
645
+ itemlist << item[7].to_s # ilen
665
646
  itemlist << " "
666
647
  if mixed_form
667
- itemlist << item[8].to_s
648
+ itemlist << item[8].to_s # field type
668
649
  itemlist << " "
669
650
  end
670
651
  end
@@ -685,9 +666,7 @@ class MRDialog
685
666
  end
686
667
  end
687
668
  cmd << " "
688
- cmd << "'"
689
- cmd << text
690
- cmd << "'"
669
+ cmd << Shellwords.escape(text) # also escape the form title
691
670
  cmd << " "
692
671
  cmd << height.to_s
693
672
  cmd << " "
@@ -714,8 +693,7 @@ class MRDialog
714
693
  return res_hash
715
694
  ensure
716
695
  tmp.close!
717
- end
718
-
696
+ end
719
697
  #
720
698
  # A mixedform dialog displays a form consisting of labels and fields,
721
699
  # much like the --form dialog. It differs by adding a field-type
@@ -754,13 +732,14 @@ class MRDialog
754
732
  # zero, the current date is used as an initial value.
755
733
  #
756
734
  # Returns a Date object with the selected date
757
-
735
+ # Update:
736
+ # insteaf of putting command inside single quote, use shell escape,
737
+ # otherwise if value has single quote parsing fails. Oct-18-2025
758
738
  def calendar(text="Select a Date", height=0, width=0, day=Date.today.mday(), month=Date.today.mon(), year=Date.today.year())
759
-
760
739
  tmp = Tempfile.new('tmp')
761
740
 
762
- command = option_string() + "--calendar \"" + text.to_s +
763
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " " +
741
+ command = option_string() + "--calendar " + Shellwords.escape(text.to_s) +
742
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " " +
764
743
  day.to_i.to_s + " " + month.to_i.to_s + " " + year.to_i.to_s +
765
744
  " 2> " + tmp.path
766
745
  success = system(command)
@@ -774,13 +753,15 @@ class MRDialog
774
753
  ensure
775
754
  tmp.close!
776
755
  end
777
-
778
756
  # A checklist box is similar to a menu box; there are multiple
779
757
  # entries presented in the form of a menu. Instead of choosing
780
758
  # one entry among the entries, each entry can be turned on or off
781
759
  # by the user. The initial on/off state of each entry is speci-
782
760
  # fied by status.
783
761
  # return an array of selected items
762
+ # Update:
763
+ # insteaf of putting command inside single quote, use shell escape,
764
+ # otherwise if value has single quote parsing fails. Oct-18-2025
784
765
  def checklist(text, items, height=0, width=0, listheight=0)
785
766
 
786
767
  tmp = Tempfile.new('tmp')
@@ -793,17 +774,18 @@ class MRDialog
793
774
  else
794
775
  item[2] = "off"
795
776
  end
796
- itemlist += "\"" + item[0].to_s + "\" \"" + item[1].to_s +
797
- "\" " + item[2] + " "
777
+ itemlist += Shellwords.escape(item[0].to_s) + " " + # tag
778
+ Shellwords.escape(item[1].to_s) + " " + # description
779
+ item[2] + " " # on/off status
798
780
 
799
781
  if @itemhelp
800
- itemlist += "\"" + item[3].to_s + "\" "
782
+ itemlist += Shellwords.escape(item[3].to_s) + " " # help text
801
783
  end
802
784
  end
803
785
 
804
786
  sep = "|"
805
- command = option_string() + "--checklist \"" + text.to_s +
806
- "\" " + height.to_i.to_s + " " + width.to_i.to_s +
787
+ command = option_string() + "--checklist " + Shellwords.escape(text.to_s) +
788
+ " " + height.to_i.to_s + " " + width.to_i.to_s +
807
789
  " " + listheight.to_i.to_s + " " + itemlist + "2> " +
808
790
  tmp.path
809
791
  log_debug "Command:\n#{command}"
@@ -827,7 +809,6 @@ class MRDialog
827
809
  ensure
828
810
  tmp.close!
829
811
  end
830
-
831
812
  # The file-selection dialog displays a text-entry window in which
832
813
  # you can type a filename (or directory), and above that two win-
833
814
  # dows with directory names and filenames.
@@ -847,12 +828,14 @@ class MRDialog
847
828
  #
848
829
  # Use a carriage return or the "OK" button to accept the current
849
830
  # value in the text-entry window and exit.
850
-
831
+ # Update:
832
+ # insteaf of putting command inside single quote, use shell escape,
833
+ # otherwise if value has single quote parsing fails. Oct-18-2025
851
834
  def fselect(path, height=0, width=0)
852
835
  tmp = Tempfile.new('tmp')
853
836
 
854
- command = option_string() + "--fselect \"" + path.to_s +
855
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
837
+ command = option_string() + "--fselect " + Shellwords.escape(path.to_s) +
838
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " "
856
839
 
857
840
  command += "2> " + tmp.path
858
841
 
@@ -872,8 +855,6 @@ class MRDialog
872
855
  ensure
873
856
  tmp.close!
874
857
  end
875
-
876
-
877
858
  #
878
859
  # An info box is basically a message box. However, in this case,
879
860
  # dialog will exit immediately after displaying the message to
@@ -882,19 +863,22 @@ class MRDialog
882
863
  # script clears it later. This is useful when you want to inform
883
864
  # the user that some operations are carrying on that may require
884
865
  # some time to finish.
885
- #
866
+ # Update:
867
+ # insteaf of putting command inside single quote, use shell escape,
868
+ # otherwise if value has single quote parsing fails. Oct-18-2025
886
869
  # Returns false if esc was pushed
887
- def infobox(text, height=0, width=0)
888
- command = option_string() + "--infobox \"" + text.to_s +
889
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
870
+ def infobox(text, height=0, width=0)
871
+ command = option_string() + "--infobox " + Shellwords.escape(text.to_s) +
872
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " "
890
873
  success = system(command)
891
874
  @exit_code = $?.exitstatus
892
875
  return success
893
- end
876
+ end
894
877
 
895
878
  # A radiolist box is similar to a menu box. The only difference
896
879
  # is that you can indicate which entry is currently selected, by
897
880
  # setting its status to true.
881
+
898
882
  def radiolist(text, items, height=0, width=0, listheight=0)
899
883
 
900
884
  tmp = Tempfile.new('tmp')
@@ -907,16 +891,17 @@ class MRDialog
907
891
  else
908
892
  item[2] = "off"
909
893
  end
910
- itemlist += "\"" + item[0].to_s + "\" \"" + item[1].to_s +
911
- "\" " + item[2] + " "
894
+ itemlist += Shellwords.escape(item[0].to_s) + " " + # tag
895
+ Shellwords.escape(item[1].to_s) + " " + # description
896
+ item[2] + " " # on/off status
912
897
 
913
898
  if @itemhelp
914
- itemlist += "\"" + item[3].to_s + "\" "
899
+ itemlist += Shellwords.escape(item[3].to_s) + " " # help text
915
900
  end
916
901
  end
917
902
 
918
- command = option_string() + "--radiolist \"" + text.to_s +
919
- "\" " + height.to_i.to_s + " " + width.to_i.to_s +
903
+ command = option_string() + "--radiolist " + Shellwords.escape(text.to_s) +
904
+ " " + height.to_i.to_s + " " + width.to_i.to_s +
920
905
  " " + listheight.to_i.to_s + " " + itemlist + "2> " +
921
906
  tmp.path
922
907
  log_debug("Command:\n#{command}")
@@ -933,35 +918,35 @@ class MRDialog
933
918
  tmp.close!
934
919
  end
935
920
 
936
- # As its name suggests, a menu box is a dialog box that can be
937
- # used to present a list of choices in the form of a menu for the
938
- # user to choose. Choices are displayed in the order given.
939
- # Each menu entry consists of a tag string and an item string.
940
- # The tag gives the entry a name to distinguish it from the other
941
- # entries in the menu. The item is a short description of the
942
- # option that the entry represents. The user can move between
943
- # the menu entries by pressing the cursor keys, the first letter
944
- # of the tag as a hot-key, or the number keys 1-9. There are
945
- # menu-height entries displayed in the menu at one time, but the
946
- # menu will be scrolled if there are more entries than that.
921
+ # As its name suggests, a menu box is a dialog box that can be
922
+ # used to present a list of choices in the form of a menu for the
923
+ # user to choose. Choices are displayed in the order given.
924
+ # Each menu entry consists of a tag string and an item string.
925
+ # The tag gives the entry a name to distinguish it from the other
926
+ # entries in the menu. The item is a short description of the
927
+ # option that the entry represents. The user can move between
928
+ # the menu entries by pressing the cursor keys, the first letter
929
+ # of the tag as a hot-key, or the number keys 1-9. There are
930
+ # menu-height entries displayed in the menu at one time, but the
931
+ # menu will be scrolled if there are more entries than that.
947
932
  #
948
- # Returns a string containing the tag of the chosen menu entry.
949
-
933
+ # Returns a string containing the tag of the chosen menu entry.
950
934
  def menu(text="Text Goes Here", items=nil, height=0, width=0, listheight=0)
951
935
  tmp = Tempfile.new('tmp')
952
936
 
953
937
  itemlist = String.new
954
938
 
955
939
  for item in items
956
- itemlist += "\"" + item[0].to_s + "\" \"" + item[1].to_s + "\" "
940
+ itemlist += Shellwords.escape(item[0].to_s) + " " + # tag
941
+ Shellwords.escape(item[1].to_s) + " " # description
957
942
 
958
943
  if @itemhelp
959
- itemlist += "\"" + item[2].to_s + "\" "
944
+ itemlist += Shellwords.escape(item[2].to_s) + " " # help text
960
945
  end
961
946
  end
962
947
 
963
- command = option_string() + "--menu \"" + text.to_s +
964
- "\" " + height.to_i.to_s + " " + width.to_i.to_s +
948
+ command = option_string() + "--menu " + Shellwords.escape(text.to_s) +
949
+ " " + height.to_i.to_s + " " + width.to_i.to_s +
965
950
  " " + listheight.to_i.to_s + " " + itemlist + "2> " +
966
951
  tmp.path
967
952
 
@@ -979,16 +964,16 @@ class MRDialog
979
964
  tmp.close!
980
965
  end
981
966
 
967
+
982
968
  # A message box is very similar to a yes/no box. The only dif-
983
969
  # ference between a message box and a yes/no box is that a mes-
984
970
  # sage box has only a single OK button. You can use this dialog
985
971
  # box to display any message you like. After reading the mes-
986
972
  # sage, the user can press the ENTER key so that dialog will exit
987
973
  # and the calling shell script can continue its operation.
988
-
989
974
  def msgbox(text="Text Goes Here", height=0, width=0)
990
- command = option_string() + "--msgbox \"" + text.to_s +
991
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
975
+ command = option_string() + "--msgbox " + Shellwords.escape(text.to_s) +
976
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " "
992
977
 
993
978
  log_debug "Command\n#{command}"
994
979
  success = system(command)
@@ -1004,14 +989,13 @@ class MRDialog
1004
989
  # confusing to the user to provide them with a default password
1005
990
  # they cannot see. For these reasons, using "init" is highly
1006
991
  # discouraged.
1007
-
1008
992
  def passwordbox(text="Please enter some text", height=0, width=0, init="")
1009
993
  tmp = Tempfile.new('tmp')
1010
- command = option_string() + "--passwordbox \"" + text.to_s +
1011
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
994
+ command = option_string() + "--passwordbox " + Shellwords.escape(text.to_s) +
995
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " "
1012
996
 
1013
997
  unless init.empty?
1014
- command += init.to_s + " "
998
+ command += Shellwords.escape(init.to_s) + " "
1015
999
  end
1016
1000
 
1017
1001
  command += "2> " + tmp.path
@@ -1032,7 +1016,7 @@ class MRDialog
1032
1016
  ensure
1033
1017
  tmp.close!
1034
1018
  end
1035
-
1019
+
1036
1020
  # The textbox method handles three similar dialog functions, textbox,
1037
1021
  # tailbox, and tailboxbg. They are activated by setting type to
1038
1022
  # "text", "tail", and "bg" respectively
@@ -1060,7 +1044,6 @@ class MRDialog
1060
1044
  # Display text from a file in a dialog box as a background task,
1061
1045
  # as in a "tail -f &" command. Scroll left/right using vi-style
1062
1046
  # 'h' and 'l', or arrow-keys. A '0' resets the scrolling.
1063
-
1064
1047
  def textbox(file, type="text", height=0, width=0)
1065
1048
  case type
1066
1049
  when "text"
@@ -1071,8 +1054,8 @@ class MRDialog
1071
1054
  opt = "--textboxbg"
1072
1055
  end
1073
1056
 
1074
- command = option_string() + opt +" \"" + file.to_s +
1075
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
1057
+ command = option_string() + opt + " " + Shellwords.escape(file.to_s) +
1058
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " "
1076
1059
 
1077
1060
  success = system(command)
1078
1061
  @exit_code = $?.exitstatus
@@ -1088,15 +1071,13 @@ class MRDialog
1088
1071
  # between windows.
1089
1072
  #
1090
1073
  # On exit, a Time object is returned.
1091
-
1092
- ##- def timebox(file, type="text", height=0, width=0, time=Time.now)
1093
1074
  def timebox(text, height=0, width=0, time=Time.now)
1094
- tmp = Tempfile.new('tmp')
1075
+ tmp = Tempfile.new('tmp')
1095
1076
 
1096
- command = option_string() + "--timebox \"" + text.to_s +
1097
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " " +
1098
- time.hour.to_s + " " + time.min.to_s + " " +
1099
- time.sec.to_s + " 2> " + tmp.path
1077
+ command = option_string() + "--timebox " + Shellwords.escape(text.to_s) +
1078
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " " +
1079
+ time.hour.to_s + " " + time.min.to_s + " " +
1080
+ time.sec.to_s + " 2> " + tmp.path
1100
1081
  log_debug("Command:\n#{command}")
1101
1082
  success = system(command)
1102
1083
  @exit_code = $?.exitstatus
@@ -1122,11 +1103,11 @@ class MRDialog
1122
1103
  def inputbox(text="Please enter some text", height=0, width=0, init="")
1123
1104
  tmp = Tempfile.new('tmp')
1124
1105
 
1125
- command = option_string() + "--inputbox \"" + text.to_s +
1126
- "\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
1106
+ command = option_string() + "--inputbox " + Shellwords.escape(text.to_s) +
1107
+ " " + height.to_i.to_s + " " + width.to_i.to_s + " "
1127
1108
 
1128
1109
  unless init.empty?
1129
- command += init.to_s + " "
1110
+ command += Shellwords.escape(init.to_s) + " "
1130
1111
  end
1131
1112
 
1132
1113
  command += "2> " + tmp.path
@@ -1149,6 +1130,7 @@ class MRDialog
1149
1130
  tmp.close!
1150
1131
  end
1151
1132
 
1133
+
1152
1134
  # A yes/no dialog box of size height rows by width columns will
1153
1135
  # be displayed. The string specified by text is displayed inside
1154
1136
  # the dialog box. If this string is too long to fit in one line,
@@ -1159,34 +1141,25 @@ class MRDialog
1159
1141
  # that require the user to answer either yes or no. The dialog
1160
1142
  # box has a Yes button and a No button, in which the user can
1161
1143
  # switch between by pressing the TAB key.
1162
-
1163
1144
  # changing --inputbox to --yesno
1164
1145
  # muquit@muquit.com Apr-01-2014
1165
- def yesno(text="Please enter some text", height=0, width=0)
1166
- # command = option_string() + "--inputbox \"" + text.to_s +
1167
- # "\" " + height.to_i.to_s + " " + width.to_i.to_s
1168
-
1146
+ def yesno(text="Please enter some text", height=0, width=0)
1169
1147
  command = ""
1170
- command << option_string();
1148
+ command << option_string()
1171
1149
  command << " "
1172
- command << "'"
1173
1150
  command << "--yesno"
1174
- command << "'"
1175
1151
  command << " "
1176
- command << "'"
1177
- command << text
1178
- command << "'"
1152
+ command << Shellwords.escape(text)
1179
1153
  command << " "
1180
1154
  command << height.to_s
1181
1155
  command << " "
1182
1156
  command << width.to_s
1183
1157
 
1184
-
1185
1158
  log_debug("Command:\n#{command}")
1186
1159
  success = system(command)
1187
1160
  @exit_code = $?.exitstatus
1188
1161
  return success
1189
- end
1162
+ end
1190
1163
 
1191
1164
  private
1192
1165
 
@@ -1199,7 +1172,7 @@ class MRDialog
1199
1172
  ostring = exe_loc
1200
1173
  else
1201
1174
  exe_loc = @path_to_dialog
1202
- if !File.exists?(exe_loc)
1175
+ if !File.exist?(exe_loc)
1203
1176
  raise "Specified path of dialog '#{exe_loc}' does not exist"
1204
1177
  end
1205
1178
  if !File.executable?(exe_loc)
@@ -1226,7 +1199,7 @@ class MRDialog
1226
1199
  end
1227
1200
 
1228
1201
  if @backtitle
1229
- ostring += "--backtitle \"" + @backtitle + "\" "
1202
+ ostring += "--backtitle " + Shellwords.escape(@backtitle) + " "
1230
1203
  end
1231
1204
 
1232
1205
  if @itemhelp
@@ -1264,9 +1237,7 @@ class MRDialog
1264
1237
  end
1265
1238
 
1266
1239
  if @title
1267
- # ostring += "--title " + "\"" + @title.to_s "\"" + " "
1268
- # muquit@muquit.com Apr-01-2014
1269
- ostring += "--title \"" + @title.to_s + "\" "
1240
+ ostring += "--title " + Shellwords.escape(@title.to_s) + " "
1270
1241
  end
1271
1242
 
1272
1243
  # muquit@muquit.com mod starts--