<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Yeah!I think yours is <span style="font-family:'Microsoft YaHei';font-size:12.800000190734863px;white-space:nowrap">elegant and simple!</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 11, 2014 at 6:33 PM, Christophe Fergeau <span dir="ltr"><<a href="mailto:cfergeau@redhat.com" target="_blank">cfergeau@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey,<br>
<div class=""><br>
On Fri, Aug 08, 2014 at 08:33:59PM +0800, Cody Chan wrote:<br>
> Hi, as you can see, in vd_agent/file_xfer.cpp, it implemented<br>
> the g_key_get_string,<br>
> but I find a problem, when dragging a file with a name containing '[' (like<br>
> te[st.txt), it will be failed.<br>
> From source code,<br>
> >next_group_pos = strstr(group_pos + strlen(group_pfx), "[");<br>
> > if (next_group_pos && key_pos > next_group_pos) return false;<br>
> we know that it tries to find the end of current group by '[' label,<br>
> if we drag a file like te[st.txt, the key_string many like:<br>
> [vdagent-file-xfer]<br>
> name=te[st.txt<br>
> size=10<br>
> so, it's failed when meta parsing and<br>
> returns VD_AGENT_FILE_XFER_STATUS_ERRO message.<br>
><br>
> I find a way to fix it, just replace '[' ']' with '<' '>' between group<br>
> name,<br>
> for it's illegal for windows to create a file with a name containing<br>
> '<'/'>'.<br>
<br>
</div>Unfortunately, I don't think we can change the file format at this<br>
point, especially as this format is based on the somehow standard 'ini'<br>
file format, and apart from the windows agent, we use glib<br>
GKeyFile parser to handle this format.<br>
>From a quick look at the code, wouldn't the patch below avoid the issue<br>
you described?<br>
<br>
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp<br>
index c258926..17cdb3c 100644<br>
--- a/vdagent/file_xfer.cpp<br>
+++ b/vdagent/file_xfer.cpp<br>
@@ -203,7 +203,7 @@ bool FileXfer::g_key_get_string(char* data, const<br>
char* grou<br>
sprintf_s(key_pfx, sizeof(key_pfx), "\n%s=", key);<br>
<div class=""> if (!(key_pos = strstr(group_pos, key_pfx))) return false;<br>
<br>
- next_group_pos = strstr(group_pos + strlen(group_pfx), "[");<br>
</div>+ next_group_pos = strstr(group_pos + strlen(group_pfx), "\n[");<br>
<div class="HOEnZb"><div class="h5"> if (next_group_pos && key_pos > next_group_pos) return false;<br>
<br>
start = key_pos + strlen(key_pfx);<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">Christophe<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font color="#cfe2f3">Q</font><font color="#9fc5e8">S</font><font color="#6fa8dc">B</font><font color="#3d85c6">D</font><font color="#0b5394">T</font><font color="#073763">0</font><font color="#0c343d">R</font><font color="#134f5c">F</font><font color="#45818e">U</font><font color="#76a5af">i</font><font color="#a2c4c9">B</font><font color="#d0e0e3">G</font><font color="#d9ead3">U</font><font color="#b6d7a8">k</font><font color="#93c47d">9</font><font color="#6aa84f">N</font><font color="#38761d">I</font><font color="#274e13">F</font><font color="#7f6000">J</font><font color="#bf9000">J</font><font color="#f1c232">R</font><font color="#ffd966">V</font><font color="#ffe599">N</font><font color="#fff2cc">U</font><font color="#fce5cd">I</font><font color="#f9cb9c">E</font><font color="#f6b26b">9</font><font color="#e69138">G</font><font color="#b45f06">I</font><font color="#783f04">E</font><font color="#660000">N</font><font color="#990000">U</font><font color="#cc0000">U</font><font color="#e06666">0V</font><font color="#ea9999">V</font></div>
</div>