version bump 0.4.1: terminating infinite loop

Infinite loop caused by invalid format string without proper end check.  It was
introduced :)
This commit is contained in:
SheetJS 2013-12-31 11:38:31 -05:00
parent 43f8f00ef5
commit e9482bfa26
4 changed files with 9 additions and 6 deletions

@ -1,6 +1,6 @@
{
"name": "ssf",
"version": "0.4.0",
"version": "0.4.1",
"author": "SheetJS",
"description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes",
"keywords": [ "format", "sprintf", "spreadsheet" ],

2
ssf.js

@ -257,7 +257,7 @@ function eval_fmt(fmt, v, opts, flen) {
while(i < fmt.length) {
switch((c = fmt[i])) {
case '"': /* Literal text */
for(o="";fmt[++i] !== '"';) o += fmt[i];
for(o="";fmt[++i] !== '"' && i < fmt.length;) o += fmt[i];
out.push({t:'t', v:o}); ++i; break;
case '\\': var w = fmt[++i], t = "()".indexOf(w) === -1 ? 't' : w;
out.push({t:t, v:w}); ++i; break;

9
ssf.md

@ -426,11 +426,14 @@ function eval_fmt(fmt, v, opts, flen) {
```
Text between double-quotes are treated literally, and individual characters are
literal if they are preceded by a slash:
literal if they are preceded by a slash.
The additional `i < fmt.length` guard was added due to potentially unterminated
strings generated by LO:
```
case '"': /* Literal text */
for(o="";fmt[++i] !== '"';) o += fmt[i];
for(o="";fmt[++i] !== '"' && i < fmt.length;) o += fmt[i];
out.push({t:'t', v:o}); ++i; break;
case '\\': var w = fmt[++i], t = "()".indexOf(w) === -1 ? 't' : w;
out.push({t:t, v:w}); ++i; break;
@ -805,7 +808,7 @@ test:
```json>package.json
{
"name": "ssf",
"version": "0.4.0",
"version": "0.4.1",
"author": "SheetJS",
"description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes",
"keywords": [ "format", "sprintf", "spreadsheet" ],

@ -257,7 +257,7 @@ function eval_fmt(fmt, v, opts, flen) {
while(i < fmt.length) {
switch((c = fmt[i])) {
case '"': /* Literal text */
for(o="";fmt[++i] !== '"';) o += fmt[i];
for(o="";fmt[++i] !== '"' && i < fmt.length;) o += fmt[i];
out.push({t:'t', v:o}); ++i; break;
case '\\': var w = fmt[++i], t = "()".indexOf(w) === -1 ? 't' : w;
out.push({t:t, v:w}); ++i; break;