Coder Social home page Coder Social logo

jsonic's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsonic's Issues

quotes in stringify

I'm having a problem with the stringify function.

doing such:

console.log( jsonic.stringify( {a:"bc",d:1} )

results in following output: {a:bc,d:1}

but i want it to output: {a:'bc',d:1} instead of {a:bc,d:1}. I need the quotes for my project. Can somebody please help me in how to fix it?

Prototype Pollution Vulnerability Affecting @jsonic/jsonic-next module, versions *

Overview

A Prototype Pollution vulnerability Affecting @jsonic/jsonic-next, due to missing check if the argument resolves to the object prototype. This allow the attacker to inject malicious object property using the built-in Object property __proto__ which recursively assigned to all the objects in the program.

Details sent directly to the maintainer

Several issues

I've been testing jsonic for a few minutes and discovered several issues:

  1. JSON file can contain just a number or string:
JSON.parse('0')
// -> 0
JSON.parse('"a string"')
// -> 'a string'

jsonic cannot parse this, but should be compatible to JSON.

  1. Hexadecimal number support ?
{ 0x12: 0x14 }
// -> { '18': 20 }
jsonic('{0x12:0x14}')
{ '0x12': '0x14' }

The result is not what I expected (same result as in JS). Hexadecimal numbers could be supported.
And invalid numbers like 0g12 could cause a parse error.

  1. Strings without quote

I don't really like that way string don't require quotes. It can confuse and it's not much work to add two quotes.

Example:

var name = 'John Doe';
var o = { name: name }

I don't need to tell what the result of js and jsonic is.
And { name: John Joe } is not even valid JS.
Better: disable that by default, and require quotes.
If the programmer badly wants the short syntax, it could be turned on optionally.

pegjs does not generate a fresh jsonic-parser.js

There seems to be some sort of issue with pegjs, - the --export-var option of pegjs in particular.

Running $ npm run-script build outputs a warning:

Can't use the -e/--export-var option with the "commonjs" module format.

The jsonic-parser.js file is not being generated:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Specifying --format globals or building without the --export-var option remedies the problem and generates a new jsonic-parser.js file. However, this change breaks the rest of the build script.

SyntaxError: Expected "," or "]" but "\\" found.

{ [SyntaxError: Expected "," or "]" but "\\" found.]
  message: 'Expected "," or "]" but "\\\\" found.',
  expected:
   [ { type: 'literal', value: ',', description: '","' },
     { type: 'literal', value: ']', description: '"]"' } ],
  found: '\\',
  offset: 210,
  line: 1,
  column: 211,
  name: 'SyntaxError' }

Input was

[ '\\uC774\\uB7F0 \\uB958\\uC758 \\uB3C4\\uC11C\\uB97C \\uC88B\\uC544\\uD558\\uC9C0 \\uC54A\\uC74C\\uC5D0\\uB3C4 \\uBD88\\uAD6C\\uD558\\uACE0 \\uC774 \\uCC45\\uC744 \\uC9D1\\uC5B4\\uB4E0 \\uC774\\uC720\\uB294 \\uB2E8\\uC21C\\uD558\\uB2E4. \\',
  '\\uC778\\uD130\\uD30C\\uD06C\\uB3C4\\uC11C',
  'HelloET',
  '20170321',
  'http://book.interpark.com/blog/HelloET/4829812',
  '\\uC790\\uC874\\uAC10 \\uC218\\uC5C5\\uC744 \\uC77D\\uACE0' ]

or(it might be escaped)

[ '\\uC774\\uB7F0 \\uB958\\uC758 \\uB3C4\\uC11C\\uB97C \\uC88B\\uC544\\uD558\\uC9C0 \\uC54A\\uC74C\\uC5D0\\uB3C4 \\uBD88\\uAD6C\\uD558\\uACE0 \\uC774 \\uCC45\\uC744 \\uC9D1\\uC5B4\\uB4E0 \\uC774\\uC720\\uB294 \\uB2E8\\uC21C\\uD558\\uB2E4. \\',
  '\\uC778\\uD130\\uD30C\\uD06C\\uB3C4\\uC11C',
  'HelloET',
  '20170321',
  'http://book.interpark.com/blog/HelloET/4829812',
  '\\uC790\\uC874\\uAC10 \\uC218\\uC5C5\\uC744 \\uC77D\\uACE0' ]

javascript code was...(data was raw data so i should parse this like)

jsonic(`["${data.join('","')}"]`)

Input was just array that includes strings, but there is double backslash.
I guess this is caused by backslash(escaped) element in array.

parser ignores array[0] if value is 0

using node 4.2.4 attempting to parse an array where the value of index[0] is 0 - parser drops the index and shortens the array length by 1.

Examples in node repl:

foo = '{foo:"bar", arr:[0,0]}'
'{foo:"bar", arr:[0,0]}'
jsonic(foo)
{ foo: 'bar', arr: [ 0 ] }
foo = '{foo:"bar", arr:[0,0,0]}'
'{foo:"bar", arr:[0,0,0]}'
jsonic(foo)
{ foo: 'bar', arr: [ 0, 0 ] }
foo = '{foo:"bar", arr:[0,0,1]}'
'{foo:"bar", arr:[0,0,1]}'
jsonic(foo)
{ foo: 'bar', arr: [ 0, 1 ] }
foo = '{foo:"bar", arr:[1,0,1]}'
'{foo:"bar", arr:[1,0,1]}'
jsonic(foo)
{ foo: 'bar', arr: [ 1, 0, 1 ] }
foo = '{foo:"bar", arr:[0,1,1]}'
'{foo:"bar", arr:[0,1,1]}'
jsonic(foo)
{ foo: 'bar', arr: [ 1, 1 ] }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.