TheBrusMeister / harviewer

Automatically exported from code.google.com/p/harviewer
0 stars 0 forks source link

jsonSchema.js does not allow null for string types #102

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
PhantomJS netsniff.js sometimes generates har files with mimeType set to null, 
especially when errors occur, this causes the parsing to return an error rather 
than the expected output.

I'm not sure if this is completely valid (it's a bit of a hack) but everything 
worked after I fixed the code to allow null for strings. I tested this on GIT 
revision ID 513827c6e1ad93eaf61b19ef62eb6b47c1a3aa9c.

Here is a patch to ignore null strings in jsonSchema.js where the error is 
detected.

--- 
harviewer.513827c6e1ad93eaf61b19ef62eb6b47c1a3aa9c.git/webapp/scripts/preview/js
onSchema.js 2015-07-02 09:02:22.216114627 +0100
+++ harviewer/webapp/scripts/preview/jsonSchema.js  2015-07-02 
08:46:49.002420427 +0100
@@ -77,6 +77,7 @@
                if(typeof type == 'string' && type != 'any' && 
                        (type == 'null' ? value !== null : typeof value != type) && 
                        !(value instanceof Array && type == 'array') &&
+                       !(value === null && type == 'string') &&
                        !(type == 'integer' && value%1===0)){
                    return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}];
                }

Original issue reported on code.google.com by steveble...@googlemail.com on 15 Jul 2015 at 8:21

GoogleCodeExporter commented 8 years ago
Thanks for the report and patch!

Note that this issue list is deprecated and new reports should be done here:
https://github.com/janodvarko/harviewer/issues

Can you please move it there?

Honza

Original comment by odva...@gmail.com on 16 Jul 2015 at 8:13