Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android4.1-4.3][v0.39]WebView source={{html}} show all html string without parse html if 'baseUrl' is set #11753

Closed
peichao01 opened this issue Jan 6, 2017 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@peichao01
Copy link

peichao01 commented Jan 6, 2017

Description

use source={{baseUrl: 'xx', html:<h1>Hi</h1><script>alert(1);</script>}}
Android4.3 looks like treat webview as , will output all html string in View,
use html=xxx or source={{html:xxx}} works

Reproduction

very simple code will reproduce:

export default class RootComponent extends Component {
  render() {
    // return this.render2();
    return this.render1();
  }
  // warn, but works!! except can not alert
  render2 () {
    return (
      <WebView
        // html="<h1>H1</h1><script>alert(1);</script>" // or the following works
        source={{html: "<h1>H1</h1><script>alert(1);</script>"}}
      />
    )
  }
  // will show all html string in View like <Text> label
  render1 () {
    return (
      <WebView
        source={{
          baseUrl: 'http://test.com',
          html="<h1>H1</h1><script>alert(1);</script>"
        }}
      />
    )
  }
}

wechatimg21
wechatimg22

Solution

Additional Information

  • React Native version: [v0.39]
  • Platform: [Android4.1-4.3, not test Android4.4]
  • Operating System: [MacOS]
@peichao01 peichao01 changed the title [Android<5][v0.39]WebView source html not work [Android4.1-4.3][v0.39]WebView source html not work Jan 7, 2017
@peichao01 peichao01 changed the title [Android4.1-4.3][v0.39]WebView source html not work [Android4.1-4.3][v0.39]WebView source={{html}} show all html string without parse html if 'baseUrl' is set Jan 7, 2017
@peichao01
Copy link
Author

peichao01 commented Jan 7, 2017

And, Android4.3 webview window.alert('something') doest not alert anything

@Exilz
Copy link

Exilz commented Jan 13, 2017

I can confirm this happens on RN 0.39 on my Galaxy S3 with Android 4.3.

@ivanzotov
Copy link
Contributor

same issue

@Exilz
Copy link

Exilz commented Jan 24, 2017

Same thing happened in the NativeScript project, looks like the solution is quite simple
NativeScript/NativeScript#1038

Etheryte pushed a commit to Etheryte/react-native that referenced this issue May 4, 2017
Resolves facebook#11753. Android versions 4.1-4.3 don't understand the MIME type 'text/html; charset=utf-8' and default to 'text/plain' instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type should have no negative effects.
Etheryte pushed a commit to Etheryte/react-native that referenced this issue May 5, 2017
Resolves facebook#11753. Android versions 4.1-4.3 don't understand the MIME type 'text/html; charset=utf-8' and default to 'text/plain' instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type has no negative effects.
Etheryte pushed a commit to Etheryte/react-native that referenced this issue May 5, 2017
Resolves facebook#11753. Android versions 4.1-4.3 don't understand the MIME type 'text/html; charset=utf-8' and default to 'text/plain' instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type has no negative effects.
@hramos
Copy link
Contributor

hramos commented May 25, 2017

Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.

@hramos hramos closed this as completed May 25, 2017
@hramos hramos added the Icebox label May 26, 2017
@stereodenis
Copy link
Contributor

@hramos could you reopen it, cause it is still not fixed?

vikkalen added a commit to vikkalen/react-native that referenced this issue Jul 27, 2017
Resolves facebook#11753. Android versions 4.1-4.3 don't understand the MIME type 'text/html; charset=utf-8' and default to 'text/plain' instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type has no negative effects.
facebook-github-bot pushed a commit that referenced this issue Oct 4, 2017
Summary:
Resolves #11753 and #9835.

Android versions 4.1-4.3 don't understand the MIME type `text/html; charset=utf-8` and default to `text/plain` instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type has no negative effects.

The same fix has already been discussed, successfully tested and incorporated in NativeScript/NativeScript#1038.
Closes #13789

Differential Revision: D5971910

Pulled By: shergin

fbshipit-source-id: 07795bdf0f13ddb1e8eec779d1cad59244f3687e
@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
7 participants