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

Commit

Permalink
v2.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Nov 30, 2017
1 parent c785203 commit 02911d8
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 38 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

## 2.7.4 (2017-11-30)
* (iOS) Fix encoding of control characters in crash reports. Ensures crash reports are written correctly and delivered when containing U+0000 - U+001F

## 2.7.3 (2017-11-23)

* (iOS) Use `BSG_KSCrashReportWriter` header rather than `KSCrashReportWriter` for custom JSON serialization
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Bugsnag exception reporter for React Native
[![Documentation](https://img.shields.io/badge/documentation-2.7.3-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)
[![Documentation](https://img.shields.io/badge/documentation-2.7.4-blue.svg)](http://docs.bugsnag.com/platforms/react-native/)

Automatic [React Native error reporting](https://www.bugsnag.com/platforms/react-native-error-reporting/) with Bugsnag helps you detect both native OS and JavaScript errors in your React Native apps.

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 16
targetSdkVersion 23
versionCode 4
versionName '2.7.3'
versionName '2.7.4'
}
}

Expand Down
2 changes: 1 addition & 1 deletion cocoa/vendor/bugsnag-cocoa/Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#import <AppKit/AppKit.h>
#endif

NSString *const NOTIFIER_VERSION = @"5.14.0";
NSString *const NOTIFIER_VERSION = @"5.14.1";
NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa";
NSString *const BSTabCrash = @"crash";
NSString *const BSAttributeDepth = @"depth";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ void bsg_kscrw_i_writeUnknownObjectContents(
*limit -= (int)ivarCount;
for (size_t i = 0; i < ivarCount; i++) {
BSG_KSObjCIvar *ivar = &ivars[i];

if (ivar->type == NULL) {
BSG_KSLOG_ERROR("Found null ivar :(");
continue;
}

switch (ivar->type[0]) {
case 'c':
bsg_ksobjc_ivarValue(object, ivar->index, &s8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
#if BSG_KSJSONCODEC_UseKSLogger
#include "BSG_KSLogger.h"
#else
#define BSG_KSLOG_DEBUG(FMT, ...)
#define BSG_KSLOG_ERROR(FMT, ...)
#endif


/** The work buffer size to use when escaping string values.
* There's little reason to change this since nothing ever gets truncated.
*/
Expand Down Expand Up @@ -125,7 +126,7 @@ int bsg_ksjsoncodec_i_appendEscapedString(
src++) {
*dst++ = *src;
}

// Deal with complicated case (if any)
for (; src < srcEnd; src++) {
switch (*src) {
Expand Down Expand Up @@ -155,12 +156,23 @@ int bsg_ksjsoncodec_i_appendEscapedString(
*dst++ = 't';
break;
default:
unlikely_if((unsigned char)*src < ' ') {
BSG_KSLOG_DEBUG("Invalid character 0x%02x in string: %s", *src,
string);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;

// escape control chars (U+0000 - U+001F)
// see https://www.ietf.org/rfc/rfc4627.txt

if ((unsigned char)*src < ' ') {
unsigned int last = *src % 16;
unsigned int first = (*src - last) / 16;

*dst++ = '\\';
*dst++ = 'u';
*dst++ = '0';
*dst++ = '0';
*dst++ = bsg_g_hexNybbles[first];
*dst++ = bsg_g_hexNybbles[last];
} else {
*dst++ = *src;
}
*dst++ = *src;
}
}
size_t encLength = (size_t)(dst - workBuffer);
Expand Down Expand Up @@ -252,7 +264,7 @@ int bsg_ksjsonbeginElement(BSG_KSJSONEncodeContext *const context,
// Add a name field if we're in an object.
if (context->isObject[context->containerLevel]) {
unlikely_if(name == NULL) {
BSG_KSLOG_DEBUG("Name was null inside an object");
BSG_KSLOG_ERROR("Name was null inside an object");
return BSG_KSJSON_ERROR_INVALID_DATA;
}
unlikely_if((result = bsg_ksjsoncodec_i_addQuotedEscapedString(
Expand Down Expand Up @@ -323,7 +335,7 @@ int bsg_ksjsonaddJSONElement(BSG_KSJSONEncodeContext *const context,
idx++;
}
unlikely_if(idx >= length) {
BSG_KSLOG_DEBUG("JSON element contained no JSON data: %s", element);
BSG_KSLOG_ERROR("JSON element contained no JSON data: %s", element);
return BSG_KSJSON_ERROR_INVALID_DATA;
}
switch (element[idx]) {
Expand All @@ -346,7 +358,7 @@ int bsg_ksjsonaddJSONElement(BSG_KSJSONEncodeContext *const context,
case '9':
break;
default:
BSG_KSLOG_DEBUG("Invalid character '%c' in: ", element[idx], element);
BSG_KSLOG_ERROR("Invalid character '%c' in: ", element[idx], element);
return BSG_KSJSON_ERROR_INVALID_DATA;
}

Expand Down Expand Up @@ -656,14 +668,14 @@ int bsg_ksjsoncodec_i_writeUTF8(unsigned int character, char **dst) {
}

// If we get here, the character cannot be converted to valid UTF-8.
BSG_KSLOG_DEBUG("Invalid unicode: 0x%04x", character);
BSG_KSLOG_ERROR("Invalid unicode: 0x%04x", character);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}

int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
char **dstString) {
unlikely_if(**ptr != '\"') {
BSG_KSLOG_DEBUG("Expected '\"' but got '%c'", **ptr);
BSG_KSLOG_ERROR("Expected '\"' but got '%c'", **ptr);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}

Expand All @@ -677,7 +689,7 @@ int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
}
}
unlikely_if(src >= end) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}
const char *const srcEnd = src;
Expand Down Expand Up @@ -729,7 +741,7 @@ int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
continue;
case 'u': {
unlikely_if(src + 5 > srcEnd) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
result = BSG_KSJSON_ERROR_INCOMPLETE;
goto failed;
}
Expand All @@ -738,15 +750,15 @@ int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
bsg_g_hexConversion[src[3]] << 4 |
bsg_g_hexConversion[src[4]];
unlikely_if(accum > 0xffff) {
BSG_KSLOG_DEBUG("Invalid unicode sequence: %c%c%c%c",
BSG_KSLOG_ERROR("Invalid unicode sequence: %c%c%c%c",
src[1], src[2], src[3], src[4]);
result = BSG_KSJSON_ERROR_INVALID_CHARACTER;
goto failed;
}

// UTF-16 Trail surrogate on its own.
unlikely_if(accum >= 0xdc00 && accum <= 0xdfff) {
BSG_KSLOG_DEBUG("Unexpected trail surrogate: 0x%04x",
BSG_KSLOG_ERROR("Unexpected trail surrogate: 0x%04x",
accum);
result = BSG_KSJSON_ERROR_INVALID_CHARACTER;
goto failed;
Expand All @@ -756,12 +768,12 @@ int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
unlikely_if(accum >= 0xd800 && accum <= 0xdbff) {
// Fetch trail surrogate.
unlikely_if(src + 11 > srcEnd) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
result = BSG_KSJSON_ERROR_INCOMPLETE;
goto failed;
}
unlikely_if(src[5] != '\\' || src[6] != 'u') {
BSG_KSLOG_DEBUG("Expected \"\\u\" but got: \"%c%c\"",
BSG_KSLOG_ERROR("Expected \"\\u\" but got: \"%c%c\"",
src[5], src[6]);
result = BSG_KSJSON_ERROR_INVALID_CHARACTER;
goto failed;
Expand All @@ -772,7 +784,7 @@ int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
bsg_g_hexConversion[src[3]] << 4 |
bsg_g_hexConversion[src[4]];
unlikely_if(accum2 < 0xdc00 || accum2 > 0xdfff) {
BSG_KSLOG_DEBUG("Invalid trail surrogate: 0x%04x",
BSG_KSLOG_ERROR("Invalid trail surrogate: 0x%04x",
accum2);
result = BSG_KSJSON_ERROR_INVALID_CHARACTER;
goto failed;
Expand All @@ -787,7 +799,7 @@ int bsg_ksjsoncodec_i_decodeString(const char **ptr, const char *const end,
continue;
}
default:
BSG_KSLOG_DEBUG("Invalid control character '%c'", *src);
BSG_KSLOG_ERROR("Invalid control character '%c'", *src);
result = BSG_KSJSON_ERROR_INVALID_CHARACTER;
goto failed;
}
Expand All @@ -811,7 +823,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
void *const userData) {
skipWhitespace(ptr, end);
unlikely_if(*ptr >= end) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}

Expand All @@ -837,7 +849,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
unlikely_if(*ptr >= end) { break; }
likely_if(**ptr == ',') { (*ptr)++; }
}
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}
case '{': {
Expand All @@ -861,7 +873,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}
unlikely_if(**ptr != ':') {
free(key);
BSG_KSLOG_DEBUG("Expected ':' but got '%c'", **ptr);
BSG_KSLOG_ERROR("Expected ':' but got '%c'", **ptr);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}
(*ptr)++;
Expand All @@ -874,7 +886,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
unlikely_if(*ptr >= end) { break; }
likely_if(**ptr == ',') { (*ptr)++; }
}
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}
case '\"': {
Expand All @@ -887,12 +899,12 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}
case 'f': {
unlikely_if(end - *ptr < 5) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}
unlikely_if(!((*ptr)[1] == 'a' && (*ptr)[2] == 'l' &&
(*ptr)[3] == 's' && (*ptr)[4] == 'e')) {
BSG_KSLOG_DEBUG("Expected \"false\" but got \"f%c%c%c%c\"",
BSG_KSLOG_ERROR("Expected \"false\" but got \"f%c%c%c%c\"",
(*ptr)[1], (*ptr)[2], (*ptr)[3], (*ptr)[4]);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}
Expand All @@ -901,12 +913,12 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}
case 't': {
unlikely_if(end - *ptr < 4) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}
unlikely_if(
!((*ptr)[1] == 'r' && (*ptr)[2] == 'u' && (*ptr)[3] == 'e')) {
BSG_KSLOG_DEBUG("Expected \"true\" but got \"t%c%c%c\"", (*ptr)[1],
BSG_KSLOG_ERROR("Expected \"true\" but got \"t%c%c%c\"", (*ptr)[1],
(*ptr)[2], (*ptr)[3]);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}
Expand All @@ -915,12 +927,12 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}
case 'n': {
unlikely_if(end - *ptr < 4) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}
unlikely_if(
!((*ptr)[1] == 'u' && (*ptr)[2] == 'l' && (*ptr)[3] == 'l')) {
BSG_KSLOG_DEBUG("Expected \"null\" but got \"n%c%c%c\"", (*ptr)[1],
BSG_KSLOG_ERROR("Expected \"null\" but got \"n%c%c%c\"", (*ptr)[1],
(*ptr)[2], (*ptr)[3]);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}
Expand All @@ -931,7 +943,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
sign = -1;
(*ptr)++;
unlikely_if(!isdigit(**ptr)) {
BSG_KSLOG_DEBUG("Not a digit: '%c'", **ptr);
BSG_KSLOG_ERROR("Not a digit: '%c'", **ptr);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}
// Fall through
Expand All @@ -958,7 +970,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}

unlikely_if(*ptr >= end) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}

Expand All @@ -972,7 +984,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}

unlikely_if(*ptr >= end) {
BSG_KSLOG_DEBUG("Premature end of data");
BSG_KSLOG_ERROR("Premature end of data");
return BSG_KSJSON_ERROR_INCOMPLETE;
}

Expand All @@ -993,7 +1005,7 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
return callbacks->onFloatingPointElement(name, value, userData);
}
}
BSG_KSLOG_DEBUG("Invalid character '%c'", **ptr);
BSG_KSLOG_ERROR("Invalid character '%c'", **ptr);
return BSG_KSJSON_ERROR_INVALID_CHARACTER;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"homepage": "https://www.bugsnag.com/platforms/react-native-error-reporting/",
"repository": "https://github.com/bugsnag/bugsnag-react-native.git",
"bugs": "https://github.com/bugsnag/bugsnag-react-native/issues",
"version": "2.7.3",
"version": "2.7.4",
"license": "MIT",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 02911d8

Please sign in to comment.