GnuCash
Contact   Instructions
Bug 796761 - Newline (char(10) is inserted into the end of the string if copy & paste text from excel into the description field of transaction
Summary: Newline (char(10) is inserted into the end of the string if copy & paste text...
Status: REOPENED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Windows (show other bugs)
Version: 3.2
Hardware: PC Windows
: Normal minor
Target Milestone: ---
Assignee: windows
QA Contact: windows
URL:
Whiteboard:
Keywords:
: 796760 797116 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-07-15 04:37 EDT by Alex Mak
Modified: 2021-02-27 13:13 EST (History)
5 users (show)

See Also:


Attachments
reconcile windows (415.26 KB, image/jpeg)
2018-07-15 04:37 EDT, Alex Mak
no flags Details

Description Alex Mak 2018-07-15 04:37:11 EDT
Step 1: Copy some text from excel
Step 2: Paste into the description field of transaction

Results : Newline (char(10) is inserted into the end of the string
1. Sqlite database shown char(10) is inserted
2. Reconcile windows shown the transaction is newlined
3. if export the transaction to CSV, extra newline is shown in the CSV file.
Comment 1 Alex Mak 2018-07-15 04:37:58 EDT
Created attachment 372918 [details]
reconcile windows
Comment 2 John Ralls 2018-07-15 09:37:49 EDT
*** Bug 796760 has been marked as a duplicate of this bug. ***
Comment 3 John Ralls 2018-07-15 09:39:24 EDT
Comment on attachment 372918 [details]
reconcile windows

What has this got to do with pasting from Excel?
Comment 4 John Ralls 2018-07-15 09:51:55 EDT
Ah, never mind, I didn't get the whole picture the first time.

FWIW this is also the case for cells pasted from libreoffice if one selects the whole cell, copies, and pastes... into emacs, or a shell window, or ...
The point being that the spreadsheet is putting the CR in the clipboard, GnuCash isn't adding it. GnuCash is working as it should.
Comment 5 Alex Mak 2018-07-15 21:12:37 EDT
(In reply to John Ralls from comment #3)
> Comment on attachment 372918 [details]
> reconcile windows
> 
> What has this got to do with pasting from Excel?

The lower part of the funds out section shown that there is 2 line for each transaction. (Upper part transaction is not copy 7 paste from excel. so it is one line only)
Comment 6 Alex Mak 2018-07-15 21:13:56 EDT
(In reply to John Ralls from comment #4)
> Ah, never mind, I didn't get the whole picture the first time.
> 
> FWIW this is also the case for cells pasted from libreoffice if one selects
> the whole cell, copies, and pastes... into emacs, or a shell window, or ...
> The point being that the spreadsheet is putting the CR in the clipboard,
> GnuCash isn't adding it. GnuCash is working as it should.

It will cause some problem if export the transaction to CSV, the format of the CSV will be corrupted ...
Comment 7 John Ralls 2018-07-15 22:33:24 EDT
So don't copy whole cell, double click on it and select only what you want to copy. Computers rather famously do what you tell them, not what you want. It's up to you to make sure that what you say and what you want are the same thing.
Comment 8 Alex Mak 2018-07-15 22:47:48 EDT
(In reply to John Ralls from comment #7)
> So don't copy whole cell, double click on it and select only what you want
> to copy. Computers rather famously do what you tell them, not what you want.
> It's up to you to make sure that what you say and what you want are the same
> thing.

I understand that there is workaround for this issues. However, in my case, the content of the cell is a format (say, =concatenate(A cell ,B cell )), it is not able to use the workaround above (Of course, it can can copy to other column and paste as text, and then paste to Gnucash ...)

Anyway, Thank you for support.
Comment 9 Alex Mak 2018-07-15 22:48:52 EDT
(In reply to Alex Mak from comment #8)
> (In reply to John Ralls from comment #7)
> > So don't copy whole cell, double click on it and select only what you want
> > to copy. Computers rather famously do what you tell them, not what you want.
> > It's up to you to make sure that what you say and what you want are the same
> > thing.
> 
> I understand that there is workaround for this issues. However, in my case,
> the content of the cell is a format (say, =concatenate(A cell ,B cell )), it
> is not able to use the workaround above (Of course, it can can copy to other
> column and paste as text, and then paste to Gnucash ...)
> 
> Anyway, Thank you for support.

Typo ... formula
Comment 10 John Ralls 2018-07-15 23:05:27 EDT
If there's a bug it's in the spreadsheets, not in GnuCash. There's no way for GnuCash to magically know that you don't want part of the clipboard pasted in.
Comment 11 Alex Mak 2018-07-15 23:08:30 EDT
(In reply to John Ralls from comment #10)
> If there's a bug it's in the spreadsheets, not in GnuCash. There's no way
> for GnuCash to magically know that you don't want part of the clipboard
> pasted in.

Understand, thank a lot.
Comment 12 Geert Janssens 2018-07-31 11:57:25 EDT
(In reply to John Ralls from comment #10)
> If there's a bug it's in the spreadsheets, not in GnuCash. There's no way
> for GnuCash to magically know that you don't want part of the clipboard
> pasted in.

Yes and no. Gnucash *can* parse out what it can't handle (or what's not wanted). I agree with Alex having a newline in a description field is unwanted and you won't be able to type it in directly. If some text pasted in does contain such a character we can omit it or replace it with a suitable replacement that does work in our registers (like a space character). That's a far better user experience than pasting with newlines.

(In reply to Alex Mak from comment #6)
> It will cause some problem if export the transaction to CSV, the format of
> the CSV will be corrupted ...

While I agree with you we should be sanitize text we receive from the clipboard this is irrelevant for the export issue you mention here. A csv file can have newlines if the fields are quoted and the gnucash csv exporter has an option to add them. If the program you use to import a gnucash csv file can't handle that, that would indeed be an issue of that program, not gnucash.
Comment 13 John Ralls 2018-07-31 12:49:56 EDT
> Gnucash *can* parse out what it can't handle (or what's not wanted).

Not easily:
gnc_item_edit_paste_clipboard (GncItemEdit *item_edit)
{
    gtk_editable_paste_clipboard(GTK_EDITABLE(item_edit->editor));
}

Gtk does expose API for manipulating the clipboard, https://developer.gnome.org/gtk3/stable/gtk3-Clipboards.html, but it can get pretty hairy, especially dealing with multiple platforms.

Probably better to do the paste and then work with the GncItemEdit's buffer to remove all of the control characters (0x00-0x1f, 0x7f-0x9f).
Comment 14 John Ralls 2021-02-27 13:13:17 EST
*** Bug 797116 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.