Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
javascript
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Dec 2014 at 14:26 UTC
Updated:
22 Apr 2015 at 12:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
chi commentedComment #2
ufku commentedDrupal.formatString converts
args['@count']to string on which the strict equality check fails.No brainer. Ready to commit.
Comment #4
chi commentedreroll
Comment #5
nod_We only use strict equals, if there is a conversion somewhere we either remove it or check for the appropriate type.
Comment #6
chi commentedI think it is no good in this particular case. We do themselves what javascript can do for us.
Comment #7
ufku commentedDrupal.formatString alters the passed args object by applying sanitizers. For strict equality we need to keep the args intact.
Comment #8
nod_@Chi, sorry should have explained more. We have coding standards for javascript, we also have an eslint configuration. Our configuration doesn't allow "sloppy equals", there is no reason to relax our standards for this.
Since we know Drupal.t() will transform all args to string, I would rather do
if (args['@count'] !== '1'), add a comment before to explain it comes from Drupal.t() escaping the value if you feel an explanation is needed.Making a new object with the arg values is a little dangerous, after calling Drupal.formatString I would expect everything to be escaped, here we end up with unsanitized values in the original arg object, and the safe values can't be accessed outside formatString.
Comment #9
ufku commentedYou shouldn't expect that. Drupal.formatString is not supposed to alter the given args. There should be another method for it, something like Drupal.sanitizeArgs.
Comment #10
nod_Yeah you're right, that was a poor attempt at justifying a one line patch instead of a proper solution.
Can you just rename
newArgsintoprocessedArgs, or something a bit more explicit than 'new'?Comment #11
ufku commentedRenamed to
processedArgsComment #12
nod_It works now, thanks!
Comment #13
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 7f5bc4e and pushed to 8.0.x. Thanks!
Comment #14
alexpottTagging in retrospect.