https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292013-04-09T12:47:39ZRedmineRedmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=480932013-04-09T12:47:39ZEtienne Massip
<ul><li><strong>Tracker</strong> changed from <i>Defect</i> to <i>Feature</i></li><li><strong>Subject</strong> changed from <i>Dots in JSONP Callback handler</i> to <i>Extend JSONP callback handler syntax support</i></li><li><strong>Target version</strong> set to <i>Candidate for next major release</i></li></ul><p>According to <a href="http://www.json-p.org" class="external">json-p.org</a> <cite>The proposed solution</cite>, allowed syntax could include these forms:<br /><pre>
functionName({JSON});
obj.functionName({JSON});
obj["function-name"]({JSON});
</pre></p>
<p>For now, only the first one is partly supported whith <cite>functionName</cite> bein composed of digits and characters A to Z plus _ (see <a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/11272/entry/trunk/lib/redmine/views/builders/json.rb#L30">source:/trunk/lib/redmine/views/builders/json.rb@11272#L30</a>).</p>
<p>Theoretically <cite>functionName</cite> should also be checked as being a <a href="http://mathiasbynens.be/notes/javascript-identifiers" class="external">valid javascript identifier name</a>, thus allowing some Unicode characters, but this might look a bit overkill?</p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=555432014-03-26T15:45:52ZKen Franqueiro
<ul></ul><p>I would definitely agree that at least <code>foo.bar(...)</code> support should be added (which I assume is what this issue originally asked for specifically, based on the subject history).</p>
<p>Some JS libraries e.g. Dojo use a global namespace for their JSONP request support so that only one global variable is created instead of multiple, and currently the regex in <a class="external" href="http://www.redmine.org/projects/redmine/repository/entry/trunk/lib/redmine/views/builders/json.rb">http://www.redmine.org/projects/redmine/repository/entry/trunk/lib/redmine/views/builders/json.rb</a> will strip periods, making Redmine's JSONP REST API unusable with these JS libraries.</p>
<p>Here's an example of the kind of function names Dojo's <code>dojo/request/script</code> module uses: <code>dojo_request_script_callbacks.dojo_request_script0</code></p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=581542014-08-18T11:46:10ZSam Blowes
<ul></ul><p>Angular JS also uses object based JSONP callbacks.</p>
<p>Please support this ! :)</p>
<p><a class="external" href="https://github.com/angular/angular.js/issues/1551">https://github.com/angular/angular.js/issues/1551</a></p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=581552014-08-18T12:43:04ZSam Blowes
<ul></ul><p>I added the dot to the regex, which at least fixes the obj.functionName({JSON}); example.</p>
<p><a class="external" href="https://github.com/blowsie/redmine/commit/6d476160cdbc4eee17ae481f873fc07dc8cdf571">https://github.com/blowsie/redmine/commit/6d476160cdbc4eee17ae481f873fc07dc8cdf571</a></p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=639432015-05-29T21:37:23ZBrian Bouterse
<ul></ul><p>I just spent several hours implementing workarounds because Redmine does not adhere to the JSONP specification. I'm still not done... I'm using Angular JS like the user in comment <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: ajax pagination of projects (Closed)" href="https://www.redmine.org/issues/3">#3</a>. This issue is years old and has a link to a commit (comment <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: log problem (Closed)" href="https://www.redmine.org/issues/4">#4</a>) that contains a 1 line fix.</p>
<p>What needs to happen for this to be included in the next Redmine release.</p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=645262015-06-28T11:16:13ZToshi MARUYAMA
<ul></ul><p>Sam Blowes wrote:</p>
<blockquote>
<p>I added the dot to the regex, which at least fixes the obj.functionName({JSON}); example.</p>
<p><a class="external" href="https://github.com/blowsie/redmine/commit/6d476160cdbc4eee17ae481f873fc07dc8cdf571">https://github.com/blowsie/redmine/commit/6d476160cdbc4eee17ae481f873fc07dc8cdf571</a></p>
</blockquote>
<p>lib/redmine/views/builders/json.rb for trunk <a class="changeset" title="Add project is_public to GET /projects/:id and /projects API response (#17628). Contributed by M..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/13339">r13339</a>:<br /><pre><code class="diff syntaxhl"><span class="p">@@ -27,7 +27,7 @@</span> def initialize(request, response)
super
callback = request.params[:callback] || request.params[:jsonp]
if callback && Setting.jsonp_enabled?
<span class="gd">- self.jsonp = callback.to_s.gsub(/[^a-zA-Z0-9_]/, '')
</span><span class="gi">+ self.jsonp = callback.to_s.gsub(/[^a-zA-Z0-9_.]/, '')
</span> end
end
</code></pre></p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=680022015-12-17T10:58:24ZSam Blowes
<ul></ul><p>Could we pretty please have this single character added to this line?</p>
<p>Just for your sanity here is a description of the regex;<br /><pre>
// [^a-zA-Z0-9_.]
//
// Options: Case sensitive; ^$ match at line breaks; dot doesn’t match line breaks; Regex syntax only
//
// Match any single character that is NOT present in the list below and that is NOT a line break character (line feed) «[^a-zA-Z0-9_.]»
// A character in the range between “a” and “z” (case sensitive) «a-z»
// A character in the range between “A” and “Z” (case sensitive) «A-Z»
// A character in the range between “0” and “9” «0-9»
// A single character from the list “_.” «_.»
</pre></p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=680042015-12-17T13:29:15ZSam Blowes
<ul></ul><p>Perhaps someone with SVN skills would kindly submit my patch to the Redmine SVN repo.<br /><a class="external" href="https://github.com/redmine/redmine/pull/68">https://github.com/redmine/redmine/pull/68</a></p>
<p>Regards.</p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=680242015-12-18T12:12:45ZSam Blowes
<ul></ul><p><a class="external" href="https://bitbucket.org/redmine/redmine/pull-requests/3/improve-jsonp-support/diff">https://bitbucket.org/redmine/redmine/pull-requests/3/improve-jsonp-support/diff</a></p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=680572015-12-21T04:44:29ZToshi MARUYAMA
<ul><li><strong>File</strong> <a href="/attachments/14891">issue-13718.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/14891/issue-13718.diff">issue-13718.diff</a> added</li><li><strong>Target version</strong> changed from <i>Candidate for next major release</i> to <i>3.3.0</i></li></ul><p>Sam Blowes wrote:</p>
<blockquote>
<p><a class="external" href="https://bitbucket.org/redmine/redmine/pull-requests/3/improve-jsonp-support/diff">https://bitbucket.org/redmine/redmine/pull-requests/3/improve-jsonp-support/diff</a></p>
</blockquote>
<p>One of reasons which pull request is bad is if source repository is deleted, diff is also deleted.</p> Redmine - Feature #13718: Accept dots in JSONP callbackhttps://www.redmine.org/issues/13718?journal_id=686202016-01-16T09:08:37ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Subject</strong> changed from <i>Extend JSONP callback handler syntax support</i> to <i>Accept dots in JSONP callback</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Fix committed, thanks.</p>