Collator::getSortKey() was returning an unterminated string
due the length given to RETURN_STRINGL being off by one.
RETURN_FALSE;
}
+ /* ucol_getSortKey is exception in that the key length includes the
+ * NUL terminator*/
key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0);
if(!key_len) {
efree( ustr );
if(!key_len) {
RETURN_FALSE;
}
- RETURN_STRINGL((char *)key, key_len, 0);
+ RETURN_STRINGL((char *)key, key_len - 1, 0);
}
/* }}} */
--- /dev/null
+--TEST--
+Bug #62070: Collator::getSortKey() returns garbage
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+$s1 = 'Hello';
+
+$coll = collator_create('en_US');
+$res = collator_get_sort_key($coll, $s1);
+
+echo urlencode($res);
+--EXPECT--
+5%2F%3D%3DC%01%09%01%8F%08