<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>185433</bug_id>
          
          <creation_ts>2009-02-24 13:31:50 +0000</creation_ts>
          <short_desc>Open/save dialog cannot open or save filenames containing double quotes</short_desc>
          <delta_ts>2020-09-23 18:23:23 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>Frameworks and Libraries</classification>
          <product>frameworks-kio</product>
          <component>Open/save dialogs</component>
          <version>5.45.0</version>
          <rep_platform>Compiled Sources</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.kde.org/show_bug.cgi?id=426728</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>testcase, usability</keywords>
          <priority>VHI</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Inge Wallin">inge</reporter>
          <assigned_to name="Andreas Bontozoglou">a.bontozoglou</assigned_to>
          <cc>a.bontozoglou</cc>
    
    <cc>adaptee</cc>
    
    <cc>adawit</cc>
    
    <cc>arthur</cc>
    
    <cc>benhuan</cc>
    
    <cc>brendon</cc>
    
    <cc>bugseforuns</cc>
    
    <cc>bugzilla.kde</cc>
    
    <cc>chshu</cc>
    
    <cc>ereslibre</cc>
    
    <cc>faure</cc>
    
    <cc>glyphimor</cc>
    
    <cc>grosser.meister.morti</cc>
    
    <cc>hessijames</cc>
    
    <cc>kdelibs-bugs-null</cc>
    
    <cc>kdespam34fb987</cc>
    
    <cc>lukasz.wojnilowicz</cc>
    
    <cc>mail</cc>
    
    <cc>nate</cc>
    
    <cc>pascal</cc>
    
    <cc>stharward</cc>
    
    <cc>walch.martin</cc>
          
          <cf_commitlink>https://invent.kde.org/frameworks/kio/commit/87adf7f6bcbd9baddafda58e2dbf7052eb323358</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>721905</commentid>
    <comment_count>0</comment_count>
    <who name="Inge Wallin">inge</who>
    <bug_when>2009-02-24 13:31:50 +0000</bug_when>
    <thetext>Version:            (using KDE 4.2.0)
Installed from:    Compiled From Sources

How to reproduce:

1. Create a file named &quot;foo.txt&quot;, including the double quotes.
2. Start kword or possibly any other editor like kate.
   This bug was discovered with kword 2.0beta6
3. Choose File -&gt; Open in the dialog.
4. Open the file

You will get an error message saying the file doesn&apos;t exist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>721908</commentid>
    <comment_count>1</comment_count>
    <who name="David Faure">faure</who>
    <bug_when>2009-02-24 13:36:45 +0000</bug_when>
    <thetext>Yes, happens with kwrite too. Must be the code for multi-selecting files (&quot;a.txt &quot;b.txt&quot;), which removes double-quotes automatically.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>850475</commentid>
    <comment_count>2</comment_count>
    <who name="Christoph Feck">cfeck</who>
    <bug_when>2009-10-25 17:04:09 +0000</bug_when>
    <thetext>*** Bug 211739 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1031081</commentid>
    <comment_count>3</comment_count>
    <who name="Christoph Feck">cfeck</who>
    <bug_when>2010-10-12 17:40:40 +0000</bug_when>
    <thetext>*** Bug 218194 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1308918</commentid>
    <comment_count>4</comment_count>
    <who name="Christoph Feck">cfeck</who>
    <bug_when>2012-10-24 20:46:42 +0000</bug_when>
    <thetext>*** Bug 308277 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1317034</commentid>
    <comment_count>5</comment_count>
    <who name="Soren Harward">stharward</who>
    <bug_when>2012-11-20 17:04:12 +0000</bug_when>
    <thetext>I ran into this bug with Amarok.  It&apos;s not just multi-select.  It&apos;s that when the dialog&apos;s selectedUrls() function is called, the URL being returned contains only the portion of the filename that&apos;s within the quotes.  So if I had the files:

/home/user/&quot;test&quot;.txt
/home/user/this_is_&quot;a_test&quot;.txt

calling KFileDialog::selectedUrls() would return

KUrl(&quot;file:///home/user/test&quot;)
KUrl(&quot;file:///home/user/a_test&quot;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1377573</commentid>
    <comment_count>6</comment_count>
    <who name="Dawit Alemayehu">adawit</who>
    <bug_when>2013-06-18 04:56:59 +0000</bug_when>
    <thetext>*** Bug 189935 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1377574</commentid>
    <comment_count>7</comment_count>
    <who name="Dawit Alemayehu">adawit</who>
    <bug_when>2013-06-18 04:59:17 +0000</bug_when>
    <thetext>Someone needs to fix KFileWidget (kdelibs/kfile/kfilewidget.cpp)... Line #1641 at contains the following statement:

             // FIXME: current implementation drawback: a filename can&apos;t contain quotes

 Unless that is resolved this problem will remain.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395646</commentid>
    <comment_count>8</comment_count>
    <who name="Daniel Faust">hessijames</who>
    <bug_when>2013-09-07 09:00:31 +0000</bug_when>
    <thetext>The multi-selection code seems to be a problem in general. E. g. selecting files containing percent signs only works in single-selection mode. Meaning there are two code paths which is bad for testing.

@Soren:
If a filename contains double quotes, it is falsely detected as a multi-selection string and everything outside of the quotes gets ignored.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1592428</commentid>
    <comment_count>9</comment_count>
    <who name="Francis Herne">mail</who>
    <bug_when>2016-05-03 21:20:37 +0000</bug_when>
    <thetext>This is more serious than it says on the tin.

It affects _saving_ files too...save to FooDoc(&quot;quotes&quot;).file, and pretty much every KDE app will write to &apos;quotes&apos;.

Best-case, the file isn&apos;t saved to where the user expected it but they notice.
Worse, it&apos;s saved somewhere else and they think they&apos;ve lost all their work.

At least there&apos;s a popup before clobbering &apos;quotes&apos; if it exists, but people aren&apos;t good at paying attention to those.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1665649</commentid>
    <comment_count>10</comment_count>
    <who name="Francis Herne">mail</who>
    <bug_when>2017-03-11 03:57:37 +0000</bug_when>
    <thetext>*** Bug 362613 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744566</commentid>
    <comment_count>11</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2018-04-10 21:57:58 +0000</bug_when>
    <thetext>*** Bug 329258 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745083</commentid>
    <comment_count>12</comment_count>
    <who name="realnobody">kdespam34fb987</who>
    <bug_when>2018-04-12 19:31:59 +0000</bug_when>
    <thetext>#c8 mentions percent signs - there are also question marks which cause problems, see Bug 329259 ... possibly a related cause.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745087</commentid>
    <comment_count>13</comment_count>
    <who name="realnobody">kdespam34fb987</who>
    <bug_when>2018-04-12 19:40:18 +0000</bug_when>
    <thetext>(In reply to realnobody from comment #12)
forget that, I just tried again - and it seems the mentioned &quot;?&quot; case if fixed in the meantime.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1773598</commentid>
    <comment_count>14</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2018-08-22 20:05:31 +0000</bug_when>
    <thetext>*** Bug 355821 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1946611</commentid>
    <comment_count>15</comment_count>
    <who name="Patrick Silva">bugseforuns</who>
    <bug_when>2020-07-27 13:20:30 +0000</bug_when>
    <thetext>*** Bug 424702 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948090</commentid>
    <comment_count>16</comment_count>
    <who name="Bug Janitor Service">bug-janitor</who>
    <bug_when>2020-08-02 10:20:27 +0000</bug_when>
    <thetext>A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/89</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948091</commentid>
    <comment_count>17</comment_count>
    <who name="Andreas Bontozoglou">a.bontozoglou</who>
    <bug_when>2020-08-02 10:24:26 +0000</bug_when>
    <thetext>Taking this over with an open MR - feel free to take back</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948183</commentid>
    <comment_count>18</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2020-08-02 13:34:30 +0000</bug_when>
    <thetext>Thanks for working on this, Andreas! Much appreciated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1957031</commentid>
    <comment_count>19</comment_count>
    <who name="David Faure">faure</who>
    <bug_when>2020-09-12 18:04:00 +0000</bug_when>
    <thetext>Git commit 87adf7f6bcbd9baddafda58e2dbf7052eb323358 by David Faure, on behalf of Andreas Bontozoglou.
Committed on 12/09/2020 at 18:03.
Pushed by dfaure into branch &apos;master&apos;.

[kio] BUG: Allowing double-quotes in open/save dialog

tl;dr: Allowing double-quotes in filenames in KFileWidget by escaping them with `\` and modifying the tokenizer to understand this.

In this patch:

- Introduce `escapeDoubleQuotes` function that is used to escape selected file paths and correctly populate the `locationEdit`

- Disabling old KFileWidgetPrivate::tokenize and writing a new one which works by iterating each character in the `locationEdit` while it remembers if it is in &quot;escape mode&quot; (seen a &apos;\&apos;) or not.

- Introducing **public API** `KFileWidget::setSelectedUrls`. This was mainly needed for the tests to work. I originally wanted to test only the tokenizer but (a) this is in private implementation and (b) testing that things are escaped properly in the text-box is also very important

- Adding a test for various filenames that contain a mix of backslashes and quotes

- Adding a new logging category for the kfilewidget.cpp (KIO_KFILEWIDGETS_FW)

- Adding command-line options to `kfilewidgettest_saving_gui` which I used for functional tests at some point. My work there is a bit sloppy atm but I assume this is an auxiliary file (let me now if you want me to clean it up)

Questions:

- Do I need to add a @since in the docblock?

- Do I need to change minor/major version here (and how would I do this)? I am not sure if the addition of `setSelectedUrls` is backwards compatible

M  +105  -0    autotests/kfilewidgettest.cpp
M  +9    -0    src/filewidgets/CMakeLists.txt
M  +98   -46   src/filewidgets/kfilewidget.cpp
M  +8    -0    src/filewidgets/kfilewidget.h
M  +25   -7    tests/kfilewidgettest_saving_gui.cpp

https://invent.kde.org/frameworks/kio/commit/87adf7f6bcbd9baddafda58e2dbf7052eb323358</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>