From 7113d087fb94a432e404163abb4e469f34a23538 Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Wed, 23 Oct 2013 10:44:27 -0700 Subject: [PATCH 1/6] Remove string encoding from Hint List and add it to Hint Insert --- src/extensions/default/UrlCodeHints/main.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/extensions/default/UrlCodeHints/main.js b/src/extensions/default/UrlCodeHints/main.js index c5d9f58599f..1647f9bd149 100644 --- a/src/extensions/default/UrlCodeHints/main.js +++ b/src/extensions/default/UrlCodeHints/main.js @@ -139,9 +139,10 @@ define(function (require, exports, module) { // convert to doc relative path var entryStr = entry.fullPath.replace(docDir, ""); - // code hints show the same strings that are inserted into text, - // so strings in list will be encoded. wysiwyg, baby! - unfiltered.push(encodeURI(entryStr)); + // code hints show the unencoded string so the + // choices are easier to read. The encoded string + // will still be inserted into the editor. + unfiltered.push(entryStr); } }); @@ -225,7 +226,7 @@ define(function (require, exports, module) { }; /** - * Determines whether font hints are available in the current editor + * Determines whether url hints are available in the current editor * context. * * @param {Editor} editor @@ -361,7 +362,7 @@ define(function (require, exports, module) { }; /** - * Returns a list of availble font hints, if possible, for the current + * Returns a list of available url hints, if possible, for the current * editor context. * * @return {jQuery.Deferred|{ @@ -504,6 +505,10 @@ define(function (require, exports, module) { */ UrlCodeHints.prototype.insertHint = function (completion) { var mode = this.editor.getModeForSelection(); + + // Encode the string just prior to inserting the hint into the editor + completion = encodeURI(completion); + if (mode === "html") { return this.insertHtmlHint(completion); } else if (mode === "css") { From d1a8d2458f64ba0cbfadf08f330cfa08e3623aad Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Thu, 24 Oct 2013 15:08:16 -0700 Subject: [PATCH 2/6] Check for partial and invalid encoded characters in URI --- src/extensions/default/UrlCodeHints/main.js | 41 ++++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/extensions/default/UrlCodeHints/main.js b/src/extensions/default/UrlCodeHints/main.js index 1647f9bd149..38b6f502223 100644 --- a/src/extensions/default/UrlCodeHints/main.js +++ b/src/extensions/default/UrlCodeHints/main.js @@ -225,6 +225,39 @@ define(function (require, exports, module) { return { hints: hints, sortFunc: sortFunc }; }; + /** + * Helper function that cleans partially or malformed encoded characters + * in a URI, then decodes it. + * + * @param {string} URI + * The current URI that needs to be cleaned and decoded + * + * @return {string} + * The clean, decoded URI. Partially typed encoded characters at the end + * of the URI are stripped off. Any encoded characters in the string that + * would make decodeURI() fail are interpreted as literal characters instead. + */ + UrlCodeHints.prototype._cleanAndDecodeURI = function (URI) { + var matchResults, + finalURI = URI; + + // If there is a partially encoded character on the end, strip it off + matchResults = finalURI.match(/%[\dA-Fa-f]?$/); // e.g. "%", "%5", "%A", "%d" + if (matchResults) { + finalURI = finalURI.substring(0, matchResults.index); + } + + // Decode any encoded characters, checking for incorrect formatting + try { + finalURI = decodeURI(finalURI); + } catch (err) { + // do nothing, finalURI does not change... + // treat all characters as literal characters + } + + return finalURI; + }; + /** * Determines whether url hints are available in the current editor * context. @@ -340,6 +373,8 @@ define(function (require, exports, module) { query = ""; } + query = this._cleanAndDecodeURI(query); + var hintsAndSortFunc = this._getUrlHints({queryStr: query}); var hints = hintsAndSortFunc.hints; if (hints instanceof Array) { @@ -357,7 +392,7 @@ define(function (require, exports, module) { } } } - + return (query !== null); }; @@ -450,7 +485,9 @@ define(function (require, exports, module) { } else { return null; } - + + query.queryStr = this._cleanAndDecodeURI(query.queryStr); + if (query.queryStr !== null) { filter = query.queryStr; var hintsAndSortFunc = this._getUrlHints(query); From 4e66521365b617a0c594ff73d2000316ccdfbf92 Mon Sep 17 00:00:00 2001 From: Narciso Jaramillo Date: Tue, 22 Oct 2013 15:45:46 -0700 Subject: [PATCH 3/6] For #5068, when autoindenting, only insert a tab if the cursor doesn't move due to CodeMirror's indentation --- src/editor/Editor.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index b0822549922..5eb15985572 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -140,10 +140,18 @@ define(function (require, exports, module) { if (indentAuto) { var currentLength = line.length; CodeMirror.commands.indentAuto(instance); - // If the amount of whitespace didn't change, insert another tab + + // If the amount of whitespace and the cursor position didn't change, we must have + // already been at the correct indentation level as far as CM is concerned, so insert + // another tab. if (instance.getLine(from.line).length === currentLength) { - insertTab = true; - to.ch = 0; + var newFrom = instance.getCursor(true), + newTo = instance.getCursor(false); + if (newFrom.line === from.line && newFrom.ch === from.ch && + newTo.line === to.line && newTo.ch === to.ch) { + insertTab = true; + to.ch = 0; + } } } else if (instance.somethingSelected() && from.line !== to.line) { CodeMirror.commands.indentMore(instance); From 1445eb3db80d6f4e6d111f4c14a832ac173cffd7 Mon Sep 17 00:00:00 2001 From: wALF Utility Date: Fri, 1 Nov 2013 20:24:05 -0700 Subject: [PATCH 4/6] Updated by ALF automation. --- src/nls/fr/strings.js | 1 + src/nls/ja/strings.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/nls/fr/strings.js b/src/nls/fr/strings.js index 6b2daa83ba5..74f342e0623 100644 --- a/src/nls/fr/strings.js +++ b/src/nls/fr/strings.js @@ -455,6 +455,7 @@ define({ "LOCALE_IT": "Italien", "LOCALE_JA": "Japonais", "LOCALE_NB": "Norvégien", + "LOCALE_FA_IR": "Perse", "LOCALE_PL": "Polonais", "LOCALE_PT_BR": "Portugais (Brésil)", "LOCALE_PT_PT": "Portugais", diff --git a/src/nls/ja/strings.js b/src/nls/ja/strings.js index df32ce8f0f8..b0158b0c468 100644 --- a/src/nls/ja/strings.js +++ b/src/nls/ja/strings.js @@ -455,6 +455,7 @@ define({ "LOCALE_IT": "イタリア語", "LOCALE_JA": "日本語", "LOCALE_NB": "ノルウェー語", + "LOCALE_FA_IR": "ペルシャ語", "LOCALE_PL": "ポーランド語", "LOCALE_PT_BR": "ポルトガル語 (ブラジル)", "LOCALE_PT_PT": "ポルトガル語", From 159a7659e83be8664757d2c45512060178a23671 Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Sun, 3 Nov 2013 10:02:35 -0800 Subject: [PATCH 5/6] If first character is partially encoded, don't strip it off --- src/extensions/default/UrlCodeHints/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/default/UrlCodeHints/main.js b/src/extensions/default/UrlCodeHints/main.js index 38b6f502223..273063d78f8 100644 --- a/src/extensions/default/UrlCodeHints/main.js +++ b/src/extensions/default/UrlCodeHints/main.js @@ -242,7 +242,7 @@ define(function (require, exports, module) { finalURI = URI; // If there is a partially encoded character on the end, strip it off - matchResults = finalURI.match(/%[\dA-Fa-f]?$/); // e.g. "%", "%5", "%A", "%d" + matchResults = finalURI.match(/^[^%]+%[\dA-Fa-f]?$/); // e.g. "%", "%5", "%A", "%d" if (matchResults) { finalURI = finalURI.substring(0, matchResults.index); } From 47086fc24cca955be795f4378b8b79017641027f Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Sun, 3 Nov 2013 14:07:28 -0800 Subject: [PATCH 6/6] Rollback matching of manually entered percent-encoded characters --- src/extensions/default/UrlCodeHints/main.js | 39 +-------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/extensions/default/UrlCodeHints/main.js b/src/extensions/default/UrlCodeHints/main.js index 273063d78f8..49e5854052a 100644 --- a/src/extensions/default/UrlCodeHints/main.js +++ b/src/extensions/default/UrlCodeHints/main.js @@ -225,39 +225,6 @@ define(function (require, exports, module) { return { hints: hints, sortFunc: sortFunc }; }; - /** - * Helper function that cleans partially or malformed encoded characters - * in a URI, then decodes it. - * - * @param {string} URI - * The current URI that needs to be cleaned and decoded - * - * @return {string} - * The clean, decoded URI. Partially typed encoded characters at the end - * of the URI are stripped off. Any encoded characters in the string that - * would make decodeURI() fail are interpreted as literal characters instead. - */ - UrlCodeHints.prototype._cleanAndDecodeURI = function (URI) { - var matchResults, - finalURI = URI; - - // If there is a partially encoded character on the end, strip it off - matchResults = finalURI.match(/^[^%]+%[\dA-Fa-f]?$/); // e.g. "%", "%5", "%A", "%d" - if (matchResults) { - finalURI = finalURI.substring(0, matchResults.index); - } - - // Decode any encoded characters, checking for incorrect formatting - try { - finalURI = decodeURI(finalURI); - } catch (err) { - // do nothing, finalURI does not change... - // treat all characters as literal characters - } - - return finalURI; - }; - /** * Determines whether url hints are available in the current editor * context. @@ -373,8 +340,6 @@ define(function (require, exports, module) { query = ""; } - query = this._cleanAndDecodeURI(query); - var hintsAndSortFunc = this._getUrlHints({queryStr: query}); var hints = hintsAndSortFunc.hints; if (hints instanceof Array) { @@ -485,9 +450,7 @@ define(function (require, exports, module) { } else { return null; } - - query.queryStr = this._cleanAndDecodeURI(query.queryStr); - + if (query.queryStr !== null) { filter = query.queryStr; var hintsAndSortFunc = this._getUrlHints(query);