Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

string conversion fix on tokenize functrion #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

string conversion fix on tokenize functrion #6

wants to merge 1 commit into from

Conversation

sespindola
Copy link

I encountered an error when trying to use js-yaml.
It generates an error on the tokenize function when parsing non-string objects.
I've added a forced string conversion which fixes the problem.
Feel free to pull if you want this.

@CrypticSwarm
Copy link
Contributor

Can you give an example on where this happens?

@cjoudrey
Copy link

I was able to reproduce this bug, but the patch sespindola submitted does not work.

The if statement should read if (typeof str != 'String').

The bug can be reproduced when passing an object to yaml.eval. The object is not casted to string which causes this error:

Object has no method 'replace' at Object.tokenize (/usr/local/lib/node/.npm/yaml/0.1.1/package/lib/yaml.js:74:19)

@CrypticSwarm
Copy link
Contributor

Two things.

  • typeof str will never === 'String' but maybe 'string'
  • you should be passing a string to yaml.eval

@cjoudrey
Copy link

cjoudrey commented Feb 7, 2011

Agreed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants