[ 
https://issues.apache.org/jira/browse/HDFS-16977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17714104#comment-17714104
 ] 

ASF GitHub Bot commented on HDFS-16977:
---------------------------------------

YuanbenWang commented on PR #5547:
URL: https://github.com/apache/hadoop/pull/5547#issuecomment-1514732281

   > > Some pathnames which contains special character(s) may lead to 
unexpected results. For example, there is a file named "/foo/file*" in my 
cluster, created by "DistributedFileSystem.create(new Path("/foo/file*"))". 
When I want to remove it, I type in "hadoop fs -rm /foo/file*" in shell. 
However, I remove all the files with the prefix of "/foo/file*" unexpectedly. 
There are also some other characters just like '*', such as ' ', '|', '&', etc.
   > 
   > Should have escaped the special character. That is how shell behaves.
   > 
   > ```
   > bash-4.2$ hdfs dfs -ls /dir
   > Found 6 items
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:41 /dir/a
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:41 /dir/ab*
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abc
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abcd
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abcde
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abcdef
   > bash-4.2$ hdfs dfs -rm -r /dir/ab\\*
   > Deleted /dir/ab*
   > bash-4.2$ hdfs dfs -ls /dir
   > Found 5 items
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:41 /dir/a
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abc
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abcd
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abcde
   > drwxr-xr-x   - hadoop supergroup          0 2023-04-17 12:42 /dir/abcdef
   > ```
   
   Thank you for your reviewing and it‘s a useful way to escape special 
character.
   
   Actually, this PR aims to offer an optional and simple way to avoid the risk 
of misoperation.




> Forbid assigned characters in pathname.
> ---------------------------------------
>
>                 Key: HDFS-16977
>                 URL: https://issues.apache.org/jira/browse/HDFS-16977
>             Project: Hadoop HDFS
>          Issue Type: New Feature
>          Components: dfsclient, namenode
>    Affects Versions: 3.3.4
>            Reporter: WangYuanben
>            Priority: Minor
>              Labels: pull-request-available
>
> Some pathnames which contains special character(s) may lead to unexpected 
> results. For example, there is a file named "/foo/file*" in my cluster, 
> created by "DistributedFileSystem.create(new Path("/foo/file*"))". When I 
> want to remove it, I type in "hadoop fs -rm /foo/file*" in shell. However, I 
> remove all the files with the prefix of "/foo/file*" unexpectedly. There are 
> also some other characters just like '*', such as ' ', '|', '&', etc.
>  
> Therefore, it's necessary to restrict the occurrence of these characters in 
> pathname. A simple but effective way is to forbid assigned characters in 
> pathname when new file or directory is created.
>  
> It is also important to add the same function on the Router model and WebHdfs 
> model. I will add them as two subtasks later.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to