Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/code/pathname.lisp
    ... ... @@ -838,14 +838,18 @@ a host-structure or string."
    838 838
     			       (%pathname-directory defaults)
    
    839 839
     			       diddle-defaults)))
    
    840 840
     
    
    841
    -    ;; A bit of sanity checking on user arguments.
    
    841
    +    ;; A bit of sanity checking on user arguments.  We don't allow a
    
    842
    +    ;; "/" or NUL in any string that's part of a pathname object.
    
    842 843
         (flet ((check-component-validity (name name-or-type)
    
    843 844
     	     (when (stringp name)
    
    844
    -	       (let ((unix-directory-separator #\/))
    
    845
    -		 (when (eq host (%pathname-host *default-pathname-defaults*))
    
    846
    -		   (when (find unix-directory-separator name)
    
    847
    -		     (warn (intl:gettext "Silly argument for a unix ~A: ~S")
    
    848
    -			   name-or-type name)))))))
    
    845
    +	       (when (eq host (%pathname-host *default-pathname-defaults*))
    
    846
    +		 (when (some #'(lambda (c)
    
    847
    +				 ;; Illegal characters are a slash or NUL.
    
    848
    +				 (case c
    
    849
    +				   ((#\/ #\null) t)))
    
    850
    +				name)
    
    851
    +		   (error _"Pathname component ~A cannot contain a slash or nul character: ~S"
    
    852
    +			   name-or-type name))))))
    
    849 853
           (check-component-validity name :pathname-name)
    
    850 854
           (check-component-validity type :pathname-type)
    
    851 855
           (mapc #'(lambda (d)
    
    ... ... @@ -856,8 +860,9 @@ a host-structure or string."
    856 860
     			  (not type))
    
    857 861
     		     (and (string= name ".")
    
    858 862
     			  (not type))))
    
    859
    -	;; 
    
    860
    -	(warn (intl:gettext "Silly argument for a unix PATHNAME-NAME: ~S") name)))
    
    863
    +	;;
    
    864
    +	(cerror _"Continue anyway"
    
    865
    +		_"PATHNAME-NAME cannot be \".\" or \"..\"")))
    
    861 866
     
    
    862 867
         ;; More sanity checking
    
    863 868
         (when dir
    

  • src/i18n/locale/cmucl.pot
    ... ... @@ -7717,7 +7717,7 @@ msgstr ""
    7717 7717
     msgid ", type="
    
    7718 7718
     msgstr ""
    
    7719 7719
     
    
    7720
    -#: src/code/print.lisp
    
    7720
    +#: src/code/pathname.lisp src/code/print.lisp
    
    7721 7721
     msgid "Continue anyway"
    
    7722 7722
     msgstr ""
    
    7723 7723
     
    
    ... ... @@ -9785,17 +9785,17 @@ msgid "~S is not allowed as a directory component."
    9785 9785
     msgstr ""
    
    9786 9786
     
    
    9787 9787
     #: src/code/pathname.lisp
    
    9788
    -msgid ""
    
    9789
    -"Makes a new pathname from the component arguments.  Note that host is\n"
    
    9790
    -"a host-structure or string."
    
    9788
    +msgid "Pathname component ~A cannot contain a slash or nul character: ~S"
    
    9791 9789
     msgstr ""
    
    9792 9790
     
    
    9793 9791
     #: src/code/pathname.lisp
    
    9794
    -msgid "Silly argument for a unix ~A: ~S"
    
    9792
    +msgid "PATHNAME-NAME cannot be \".\" or \"..\""
    
    9795 9793
     msgstr ""
    
    9796 9794
     
    
    9797 9795
     #: src/code/pathname.lisp
    
    9798
    -msgid "Silly argument for a unix PATHNAME-NAME: ~S"
    
    9796
    +msgid ""
    
    9797
    +"Makes a new pathname from the component arguments.  Note that host is\n"
    
    9798
    +"a host-structure or string."
    
    9799 9799
     msgstr ""
    
    9800 9800
     
    
    9801 9801
     #: src/code/pathname.lisp
    

  • tests/pathname.lisp
    ... ... @@ -153,4 +153,30 @@
    153 153
           ;; Now recursively delete the directory.
    
    154 154
           (assert-true (ext:delete-directory (merge-pathnames "tmp/" path)
    
    155 155
     					 :recursive t))
    
    156
    -      (assert-false (directory "tmp/")))))
    156
    +      (assert-false (directory (merge-pathnames "tmp/" path))))))
    
    157
    +
    
    158
    +(define-test issue.454.illegal-pathname-chars
    
    159
    +    (:tag :issues)
    
    160
    +  ;; A slash (Unix directory separater) is not allowed.
    
    161
    +  (assert-error 'simple-error
    
    162
    +		(make-pathname :name "a/b"))
    
    163
    +  (assert-error 'simple-error
    
    164
    +		(make-pathname :type "a/b"))
    
    165
    +  (assert-error 'simple-error
    
    166
    +		(make-pathname :directory '(:relative "a/b")))
    
    167
    +  ;; ASCII NUL characters are not allowed in Unix pathnames.
    
    168
    +  (let ((string-with-nul (concatenate 'string "a" (string #\nul) "b")))
    
    169
    +    (assert-error 'simple-error
    
    170
    +		  (make-pathname :name string-with-nul))
    
    171
    +    (assert-error 'simple-error
    
    172
    +		  (make-pathname :type string-with-nul))
    
    173
    +    (assert-error 'simple-error
    
    174
    +		  (make-pathname :directory (list :relative string-with-nul)))))
    
    175
    +  
    
    176
    +(define-test issue.454.illegal-pathname-dot
    
    177
    +    (:tag :issues)
    
    178
    +  (assert-error 'simple-error
    
    179
    +		(make-pathname :name "."))
    
    180
    +  (assert-error 'simple-error
    
    181
    +		(make-pathname :name "..")))
    
    182
    +