@@ -22,6 +22,19 @@ var interpretNumericEntities = function (str) {
2222 } ) ;
2323} ;
2424
25+ // This is what browsers will submit when the ✓ character occurs in an
26+ // application/x-www-form-urlencoded body and the encoding of the page containing
27+ // the form is iso-8859-1, or when the submitted form has an accept-charset
28+ // attribute of iso-8859-1. Presumably also with other charsets that does no contain
29+ // the ✓ character, such as us-ascii.
30+ var numericCheckmark = '✓' ;
31+
32+ // These are the raw utf-8 bytes of the checkmark as code points in a string.
33+ // It's what we end up with when the utf-8 sentinel parameter is interpreted
34+ // as iso-8859-1. When utf8Sentinel is enabled, we will use it to course-correct
35+ // and interpret the rest of the query string as utf-8.
36+ var misinterpretedCheckmark = '\xe2\x9c\x93' ;
37+
2538var parseValues = function parseQueryStringValues ( str , options ) {
2639 var obj = { } ;
2740 var cleanStr = options . ignoreQueryPrefix ? str . replace ( / ^ \? / , '' ) : str ;
@@ -43,10 +56,11 @@ var parseValues = function parseQueryStringValues(str, options) {
4356 key = options . decoder ( part . slice ( 0 , pos ) , defaults . decoder , charset ) ;
4457 val = options . decoder ( part . slice ( pos + 1 ) , defaults . decoder , charset ) ;
4558 }
59+
4660 if ( key === 'utf8' && options . utf8Sentinel ) {
47- if ( val === '✓' || val === '\xe2\x9c\x93' ) {
61+ if ( val === '✓' || val === misinterpretedCheckmark ) {
4862 charset = 'utf-8' ;
49- } else if ( val === '✓' ) {
63+ } else if ( val === numericCheckmark ) {
5064 charset = 'iso-8859-1' ;
5165 }
5266 } else {
0 commit comments