ljader / redmine-mylyn-plugin

Eclipse Mylyn integration for Redmine ( Eclipse Connector Plugin )
71 stars 48 forks source link

Line breaks changed during alternating edits with browser and plug-in #47

Open kuhmuh opened 10 years ago

kuhmuh commented 10 years ago

Hi,

I tested Redmine plug-in for eclipse and observed the following: When someone edits an issue with a browser and after that with the plug-in, line breaks in 'LONG TEXT' (custom) fields could be broken and falsely marked as changed when editing alternating with browser and plugin. This is quite annoying, because it shows changes in the history (and sent mails etc.), when no changes were made. I did not really investigate how many platform issues play a role in this but it occurred in our environment with Bitnami Redmine Stack on a Mac server. Clients were Windows and Mac OSX with almost all kind of browsers (Chrome, Safari, FF, IE ). I personally tested with OSX and FF 24 ESR and current eclipse plug-in from GitHub on Ecplise Kepler. As I observed the data is transferred as follows: Redmine sends

[DEBUG] content - << "    <customValue id="20147" customFieldId="18">[0xc3][0xb6][0xc3][0xa4][0xc3][0xbc][\r][\n]"
[DEBUG] content - << "[0xc3][0xb6][0xc3][0xa4][0xc3][0xbc][\r][\n]"
[DEBUG] content - << "</customValue>[\n]"

and Plugin sends

"18":"[0xc3][0xb6][0xc3][0xa4][0xc3][0xbc]\n[0xc3][0xb6][0xc3][0xa4][0xc3][0xbc]\n"

Thus the '\r\n' is replaced by a single '\n' w/o edit.

As fix for us internally I changed the IssueRequestEntity#writeValue() method as follows:

private static void writeValue(JSONWriter jsonWriter, String key, String value) throws JSONException {
        jsonWriter.key(key).value(value==null ? "" : value.replaceAll("\\n", "\r\n")); //$NON-NLS-1$
    }

This solves the issue for us. I don't know if this is a considerable solution for you, but maybe it helps.

Best regards Stefan