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

bug: ionic upload adds malformed UTF-8 BOM to index.html and changes Content-Security-Policy tag #562

Closed
mhartington opened this issue Aug 12, 2015 · 29 comments
Labels

Comments

@mhartington
Copy link
Member

From @waynebloss on August 12, 2015 1:38

Type: bug

Platform: all

After I ran ionic upload for my project, it changed the top of my index.html file from this:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-eval' 'unsafe-inline' *">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

to this:

&#xFEFF;<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy" content="default-src &apos;self&apos; &apos;unsafe-eval&apos; &apos;unsafe-inline&apos; *">
    <!-- ... -- >

index.html is already encoded in UTF-8 without BOM and it didn't change any of the other files which are encoded the same way. So, I have a few questions:

  • Should index.html or any other html file have a BOM?
  • Is the new Content-Security-Policy correct?
  • What should I do, if anything?

This is on Windows 10. I can try it on OS X and other various Unixes too, but I'll see what shows up here first. Thanks.

Copied from original issue: ionic-team/ionic-framework#4220

@KerryRitter
Copy link

I am also seeing this. This breaks my application every time when using Ionic Upload and Ionic View.

@okonon
Copy link

okonon commented Aug 22, 2015

Same here

@mhartington
Copy link
Member Author

@KerryRitter and @softBarbarian can you guys paste the output of your ionic info

@ghost
Copy link

ghost commented Aug 24, 2015

@mhartington Why not me?

@ghost
Copy link

ghost commented Aug 24, 2015

I'll just assume that you hate me because I complained about the UX on the Ionic issue collector. Sorry! 😄

It says Windows 8.1 but it's actually Windows 10.

Your system information:

Cordova CLI: 5.1.1
Gulp version:  CLI version 3.9.0
Gulp local:   Local version 3.9.0
Ionic Version: 1.1.0
Ionic CLI Version: 1.6.4
Ionic App Lib Version: 0.3.8
OS: Windows 8.1
Node Version: v0.12.7

@jbavari
Copy link

jbavari commented Aug 24, 2015

@waynebloss We know you are on Windows 10. We love you!

However, we're having trouble recreating this on OSX.

@waynebloss Do you have your editor open with index.html when you run ionic upload?

@jbavari jbavari self-assigned this Aug 24, 2015
@jbavari jbavari added the bug label Aug 24, 2015
@ghost
Copy link

ghost commented Aug 24, 2015

I just ran ionic upload with no editors open or editing index.html. Here is the diff on my index.html file after running it:

2015-08-24 13_25_18

You can see that it also added removed a tag-close slash to one of my style links but not the other. (update: struck bad observation from testimony)

@ghost
Copy link

ghost commented Aug 24, 2015

@jbavari Thanks!

I am planning on setting up my OS X box for Ionic one of these days anyway, so I'll try doing that right now and see what happens.

@jbavari
Copy link

jbavari commented Aug 24, 2015

@waynebloss That'd be awesome. We'd really appreciate it!

@ghost
Copy link

ghost commented Aug 24, 2015

@jbavari I also updated my bad observation from earlier. It did not add a tag-close slash, it removed one.

Admittedly, it's HTML5 and I should be able to have that self-closing tag there if I want, but I've seen problems with other tools because of them, so I should be avoiding them anyway, particularly for link tags.

@ghost
Copy link

ghost commented Aug 24, 2015

OK, I can totally reproduce this on OS X. Here is the ionic info:

Your system information:

Cordova CLI: 5.2.0
Ionic Version: 1.1.0
Ionic CLI Version: 1.6.4
Ionic App Lib Version: 0.3.8
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X Yosemite
Node Version: v0.12.7
Xcode version: Xcode 6.4 Build version 6E35b

And here is the diff after running ionic upload (same as the diff from Windows above):

diff --git a/src/www/index.html b/src/www/index.html
index ae34b24..dc4bd42 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+&#xFEFF;<!DOCTYPE html>
 <html>
 <head>
   <meta charset="utf-8">
@@ -7,7 +7,7 @@
   <title></title>
   <!-- Ionic -->å
   <link href="css/ionic.app.css" rel="stylesheet">
-  <link href="css/style.css" rel="stylesheet" />
+  <link href="css/style.css" rel="stylesheet">
   <script src="lib/ionic/js/ionic.bundle.js"></script>
   <script src="lib/ng-cordova/dist/ng-cordova.js"></script>
   <script src="cordova.js"></script>

I'll be glad to let you look at my project or remote into my machine (I use TeamViewer). There's nothing proprietary in it yet, but it's not public so just let me know where to send it (not an email, because it's kind of a big repo with images ~15MB)

@jbavari
Copy link

jbavari commented Aug 24, 2015

@waynebloss What editor do you use? Do you have it specify UTF-8?

@ghost
Copy link

ghost commented Aug 24, 2015

I have used Visual Studio, Notepad++ and nano to edit the html files in this project.

All of the other html files in my project are UTF-8 without BOM, however the www/index.html file happens to be encoded in UTF-8 with BOM today. I think I changed it last time I tested this issue and forgot to change it back. As I remember, the issue happens with the BOM or not.

@ghost
Copy link

ghost commented Aug 24, 2015

I'll remove the BOM and try it again on OS X to see if that makes a difference.

@ghost
Copy link

ghost commented Aug 24, 2015

OK, I removed the BOM and ionic upload did not add the malformed BOM to www/index.html. Here is the diff:

diff --git a/src/www/index.html b/src/www/index.html
index 0d0de0a..ff434d0 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -7,7 +7,7 @@
   <title></title>
   <!-- Ionic -->
   <link href="css/ionic.app.css" rel="stylesheet">
-  <link href="css/style.css" rel="stylesheet" />
+  <link href="css/style.css" rel="stylesheet">
   <script src="lib/ionic/js/ionic.bundle.js"></script>
   <script src="lib/ng-cordova/dist/ng-cordova.js"></script>
   <script src="cordova.js"></script>

@ghost
Copy link

ghost commented Aug 24, 2015

@jbavari It's working on Windows now too. ionic upload still changes my link tag, but it does not add the malformed UTF-8 BOM when www/index.html is encoded in UTF-8 without BOM.

The difference between today and the last time that I tried this is that I have since updated Ionic. So, looks like it's that part has been fixed! (I don't know if the change to the link tag is intended, but I myself am fine with that behavior for now. I'm going to remove the self-closing slash from that link tag now anyway.)

@ghost
Copy link

ghost commented Aug 24, 2015

I was just cleaning up my files and I see exactly what is happening now - if the file has a BOM, ionic upload re-encodes it to UTF-8 without BOM but the conversion doesn't strip the BOM, it converts the BOM to HTML.

@ghost
Copy link

ghost commented Aug 24, 2015

Final note - It turns out that Visual Studio Tools for Apache Cordova projects keep wanting to save www/index.html with a BOM even if I ask it not to or change it elsewhere. Funny thing - that's the only html file in the whole project that it does that to.

So, I reported that one to Microsoft as well. Thanks.

@lincolnberryiii
Copy link

I'm getting this too on OS X using Adobe Dreamweaver CC 2015, and it's only for single-quote characters in the www/index.html file. I've tried going to Modify > Page Properties > Title/Encoding and set Encoding to UTF-8 and "include unicode signature" was already unchecked. Yet for some reason, upon running ionic upload, single quotes revert back to &apos;. How do I go about fixing this step-by-step? (This thread is the first time I've ever seen the the BOM acronym.)

@mediastuttgart
Copy link

hey,

still experiencing this issue

Your system information:

Cordova CLI: 5.4.1
Gulp version:  CLI version 3.8.11
Gulp local:   Local version 3.9.0
Ionic Version: 1.2.1
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
ios-deploy version: 1.8.3
ios-sim version: 5.0.4
OS: Mac OS X El Capitan
Node Version: v0.12.0
Xcode version: Xcode 7.1.1 Build version 7B1005

@ghost
Copy link

ghost commented Jan 26, 2016

me too for both ionic upload and ionic package

Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
OS: Windows 7 SP1
Node Version: v4.2.4

@ghost
Copy link

ghost commented Jan 26, 2016

Whoa! Just submitted my first ever Pull Request. :)
ionic-team/ionic-app-lib#60

just a minor change, but it seems to have fixed my upload and package issue. hope it helps someone else.

@deinerson1
Copy link

I am experiencing the same issue as @lincolnberryiii regarding the Content-Security-Policy issue.

System information:
Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
OS: Distributor ID: Ubuntu Description: Ubuntu 15.10
Node Version: v0.12.10

This issue appears similar to #452

@Cordobo
Copy link

Cordobo commented Apr 19, 2016

@mhartington
I experienced the same issue with the Content Security Policy meta tag (on a Mac with Sublime/Atom as editors, UTF8 w/o BOM) - did you find a solution - apart from manually resetting it to the last commit :)

@itbeyond
Copy link

This is still happening on Windows 10 - Visual Studio 2015.
System information:
Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Version: 1.3.0
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
OS: Node Version: v4.4.4

@TamerCrea
Copy link

Hi People,
I'm experiencing the same problem working with this config under Windows 10 (64b).

Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Version: 1.3.1
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
OS:
Node Version: v4.3.1

I usually work with InteliJ WebStorm and Notepad++. I also get the same issue while uploading directly with the Windows command-line.

Any suggestion?
Thanks.

@TamerCrea
Copy link

TamerCrea commented Jun 7, 2016

Ok, people. A classmate has found a workaround for this problem. It doesn't fix it, but at least the file is correctly uploaded to IonicView and the app works properly:

  1. Open the index.html file with your text editor (I usede Notepad++)
  2. Run ionic upload and quickly swap to Notepad++
  3. As soon as you Notepad++ prompts you to reload the file (because it has changed) click "NO".
  4. Make a slight change in the file (such as adding or removing a space/line)
  5. Save the file.

Steps 3 to 5 must be made as quickly as possible. It seems that this way index.html is uploaded without the malformed code and so it works.

Hope this helps someone.

@tlancina
Copy link
Contributor

This should be fixed in the latest version of the CLI. Let us know if you're still having issues, thanks!

@tlancina
Copy link
Contributor

Also it's thanks to @jarodms6 🎉 👏 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests