question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid css attribute crashes the app

See original GitHub issue

Is this a bug report or a feature request?

Bug report

Have you read the guidelines regarding bug report?

Yes

Have you read the documentation in its entirety?

Yes

Have you made sure that your issue hasn’t already been reported/solved?

Similar issues have been reported, but I am unsure if the cause is the same.

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

The bug is reproducible on Android.

On iOS, it does not crash the app, though it does throw a JS error.

Is the bug reproductible in a production environment (not a debug one)?

Yes.

Have you been able to reproduce the bug in the provided example?

I did not use that example-- I used a snack instead. (See below.)

Environment

React: 16.13.0
React native: 0.62.2
react-native-render-html: 4.2.0

Target Platform: Android (9.0) iOS (13.4.1)

Steps to Reproduce

(Write your steps here:)

  1. Craft a html markup snippet that has an invalid css attribute value, e.g.:
<p style="margin-top: none">
  1. Include the html in a <HTML/> tag.
  2. View the screen with the above code.

Expected Behavior

I would not expect this library to figure out user error with markup tags, but it would be helpful if it would handle it consistently on both platforms. Ideally, if it it could accept a onRenderError callback so that, if the content cannot be rendered, the consumer of the HTML component can deal with it.

In this way, any kind of issue that would cause a render error could be handled in a consistent way, which would address, to some degree, these issues too:

https://github.com/archriss/react-native-render-html/issues/225 https://github.com/archriss/react-native-render-html/issues/164

Actual Behavior

On Android, the application crashes. Here’s a Firebase Crashlytics report snippet:

render-html-error-android

On iOS, the app itself does not crash, though a JS error is thrown:

render-html-error-ios

Reproducible Demo

Please visit this snack:

https://snack.expo.io/@alexwb/react-native-render-html-css-test

When the marginValue variable is set to a valid CSS value, such as the default value of 50, the app will render. If you change this to, say, “none”, the app will crash (though this behavior varies by platform).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

1reaction
jsamrcommented, Mar 19, 2021

@ajaysaini-sgvu On the 5.x branch, we handle unsupported CSS on a “blacklist” basis, so there are misses. On the 6.x, every CSS rule and value is validated or discarded by a separate CSS processor (see https://github.com/native-html/core/tree/master/packages/css-processor#readme). So the 6.x is expected to be much more resilient on that regard. See #430 to try it out.

0reactions
ajaysaini-sgvucommented, Mar 19, 2021

Any way to handle <HTML /> component so app will not crash with invalid css or content ? @jsamr

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page crashes whenever I link a CSS stylesheet on one file ...
This is my first web app which might be the issue since I'm not familiar enough with HTTP, back-end or front-end. So here's...
Read more >
invalid - CSS: Cascading Style Sheets - MDN Web Docs
The :invalid CSS pseudo-class represents any , , or other element whose contents fail to validate.
Read more >
Game crashes or closes unexpectedly - Microsoft Support
Explains what to do if a Microsoft game crashes or closes unexpectedly when you try to start the ... Right-click the game icon,...
Read more >
Review Crashes - Invalid Product I… | Apple Developer Forums
I submitted an app with a single non-consumable IAP upgrade. It crashed all the Review Teams devices (but works wonderfully on my devices)....
Read more >
Router tutorial: tour of heroes - Angular
Any other URL causes the router to throw an error and crash the app. Add a wildcard route to intercept invalid URLs and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found