You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Je...@priorityhealth.com on 2008/09/09 18:43:11 UTC

Double-XML escape bug in svn log --xml -v

We just had a problem with the XML output of svn log -xml -v. When the copyfrom-path
contains an XML special character, it gets XML encoded twice:

<paths>
<path
   action="D">/project/Jeff's File</path>
<path
   copyfrom-path="/project/Jeff&amp;apos;s File"
   copyfrom-rev="47"
   action="A">/project/Dave's File</path>
</paths>
<msg>This is Dave's now.
</msg>

In svn/svn-log.c, log_entry_receiver_xml() calls svn_xml_escape_attr_cstring()
and passes the result to svn_xml_make_open_tag(), but that function already
escapes any attribute values.

Is this documented|known|desired behavior? If not, would fixing it break anything
else?

Thanks,
-Jeff


** ** **  PRIVILEGED AND CONFIDENTIAL  ** ** **
This email transmission contains privileged and confidential information intended only for the use of the individual(s) or entity named above.  Any unauthorized review, use, disclosure or distribution is prohibited and may be a violation of law.  If you are not the intended recipient or a person responsible for delivering this message to an intended recipient, please delete the email and immediately notify the sender via the email return address or mailto:postmaster@priorityhealth.com.  Thank you.



Re: Double-XML escape bug in svn log --xml -v

Posted by Karl Fogel <kf...@red-bean.com>.
Okay, fixed in r33011.  Thanks, Jeffrey.

-Karl

Karl Fogel <kf...@red-bean.com> writes:
> <Je...@priorityhealth.com> writes:
>> We just had a problem with the XML output of svn log ?xml -v. When the
>> copyfrom-path
>> contains an XML special character, it gets XML encoded twice:
>>  
>> <paths>
>> <path
>>    action="D">/project/Jeff's File</path>
>> <path
>>    copyfrom-path="/project/Jeff&amp;apos;s File"
>>    copyfrom-rev="47"
>>    action="A">/project/Dave's File</path>
>> </paths>
>> <msg>This is Dave's now.
>> </msg>
>>  
>> In svn/svn-log.c, log_entry_receiver_xml() calls svn_xml_escape_attr_cstring()
>> and passes the result to svn_xml_make_open_tag(), but that function already
>> escapes any attribute values.
>>  
>> Is this documented|known|desired behavior? If not, would fixing it break
>> anything else?
>
> Definitely undesirable, and thank you for tracing the problem into the
> code.  I'm testing the patch below right now; if it passes the
> regression tests, I'll commit it.
>
> [[[
> * subversion/svn/log-cmd.c
>   (log_entry_receiver_xml): Don't double-escape the copyfrom_path;
>     svn_xml_make_open_tag will escape it anyway.
>
> Found by: Jeffrey Klein <Je...@priorityhealth.com>
> (He not only reported the bug, but located the problem in the code.)
> ]]]
>
> Index: subversion/svn/log-cmd.c
> ===================================================================
> --- subversion/svn/log-cmd.c	(revision 33010)
> +++ subversion/svn/log-cmd.c	(working copy)
> @@ -381,14 +381,11 @@
>                && SVN_IS_VALID_REVNUM(log_item->copyfrom_rev))
>              {
>                /* <path action="X" copyfrom-path="xxx" copyfrom-rev="xxx"> */
> -              svn_stringbuf_t *escpath = svn_stringbuf_create("", pool);
> -              svn_xml_escape_attr_cstring(&escpath,
> -                                          log_item->copyfrom_path, pool);
>                revstr = apr_psprintf(pool, "%ld",
>                                      log_item->copyfrom_rev);
>                svn_xml_make_open_tag(&sb, pool, svn_xml_protect_pcdata, "path",
>                                      "action", action,
> -                                    "copyfrom-path", escpath->data,
> +                                    "copyfrom-path", log_item->copyfrom_path,
>                                      "copyfrom-rev", revstr, NULL);
>              }
>            else
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Double-XML escape bug in svn log --xml -v

Posted by Karl Fogel <kf...@red-bean.com>.
<Je...@priorityhealth.com> writes:
> We just had a problem with the XML output of svn log ?xml -v. When the
> copyfrom-path
> contains an XML special character, it gets XML encoded twice:
>  
> <paths>
> <path
>    action="D">/project/Jeff's File</path>
> <path
>    copyfrom-path="/project/Jeff&amp;apos;s File"
>    copyfrom-rev="47"
>    action="A">/project/Dave's File</path>
> </paths>
> <msg>This is Dave's now.
> </msg>
>  
> In svn/svn-log.c, log_entry_receiver_xml() calls svn_xml_escape_attr_cstring()
> and passes the result to svn_xml_make_open_tag(), but that function already
> escapes any attribute values.
>  
> Is this documented|known|desired behavior? If not, would fixing it break
> anything else?

Definitely undesirable, and thank you for tracing the problem into the
code.  I'm testing the patch below right now; if it passes the
regression tests, I'll commit it.

[[[
* subversion/svn/log-cmd.c
  (log_entry_receiver_xml): Don't double-escape the copyfrom_path;
    svn_xml_make_open_tag will escape it anyway.

Found by: Jeffrey Klein <Je...@priorityhealth.com>
(He not only reported the bug, but located the problem in the code.)
]]]

Index: subversion/svn/log-cmd.c
===================================================================
--- subversion/svn/log-cmd.c	(revision 33010)
+++ subversion/svn/log-cmd.c	(working copy)
@@ -381,14 +381,11 @@
               && SVN_IS_VALID_REVNUM(log_item->copyfrom_rev))
             {
               /* <path action="X" copyfrom-path="xxx" copyfrom-rev="xxx"> */
-              svn_stringbuf_t *escpath = svn_stringbuf_create("", pool);
-              svn_xml_escape_attr_cstring(&escpath,
-                                          log_item->copyfrom_path, pool);
               revstr = apr_psprintf(pool, "%ld",
                                     log_item->copyfrom_rev);
               svn_xml_make_open_tag(&sb, pool, svn_xml_protect_pcdata, "path",
                                     "action", action,
-                                    "copyfrom-path", escpath->data,
+                                    "copyfrom-path", log_item->copyfrom_path,
                                     "copyfrom-rev", revstr, NULL);
             }
           else

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org