spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
816 stars 256 forks source link

Invalid UTF-8 Byte sequence #10

Closed fivetwentysix closed 10 years ago

fivetwentysix commented 13 years ago

http://127.0.0.1:51723/assets/tinymce/plugins/spellchecker/editor_plugin.js?3.4.5:1 Error: Sprockets::EncodingError: /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/tinymce-rails-3.4.5/assets/precompiled/tinymce/plugins/spellchecker/editor_plugin.js has a invalid UTF-8 byte sequence

I have a feeling this is causing my tests to behave in a weird way.

Can we get this fixed?

spohlenz commented 13 years ago

So the problem is that the spellchecker plugin's javascript has some (UTF-16?) characters that don't seem to play nice when processed by Sprockets. The quick solution is to make sure that config.serve_static_assets is disabled.

I can preprocess the javascript files distributed by TinyMCE but I'm not sure if that will have any undesired effects. Another possible option is to mount the assets in a different manner for development mode (currently I'm just adding the TinyMCE files to the Sprockets load paths).

Is it possible to set config.serve_static_assets = false in your situation?

fivetwentysix commented 13 years ago

Still getting tons of errors.

Feature: Payment object comments
  In order to explain a action I performed on a payment object
  As a user
  I want to make a comment

  @wip @javascript
  Scenario: Creating a comment                         # features/payment_objects/comments.feature:8
[paperclip] Saving attachments.
[paperclip] Saving attachments.
[paperclip] Saving attachments.
    Given I am in a company                            # features/step_definitions/application_steps.rb:1
    And I have created 1 cash requisition             # features/step_definitions/payment_steps.rb:5
    When I am on the requisitions page                 # features/step_definitions/web_steps.rb:44
    And I click on the 1st requisition                 # features/step_definitions/payment_steps.rb:39
    When I open the Comments tab                       # features/step_definitions/payment_steps.rb:101
http://127.0.0.1:55108/assets/tinymce/themes/advanced/editor_template.js?3.4.5:1 SyntaxError: Parse error
    When I fill in "comment_content" with "Testing123" # features/step_definitions/web_steps.rb:64
http://127.0.0.1:55108/assets/tinymce/plugins/fullscreen/editor_plugin.js?3.4.5:1 SyntaxError: Parse error
    And I click on "Comment"                           # features/step_definitions/web_steps.rb:52
http://127.0.0.1:55108/assets/tinymce/langs/en.js?3.4.5:1 SyntaxError: Parse error
    Then there should be a comment saying "Testing123" # features/step_definitions/payment_steps.rb:106
http://127.0.0.1:55108/assets/tinymce/themes/advanced/editor_template.js?3.4.5:1 SyntaxError: Parse error
      NoMethodError: undefined method `nfields' for nil:NilClass:           SELECT tablename
                FROM pg_tables
                WHERE schemaname = ANY (current_schemas(false))
       (ActiveRecord::StatementInvalid)
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in `method_missing'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:490:in `result_as_array'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:533:in `block in query'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:532:in `query'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:666:in `tables'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/truncation.rb:123:in `tables_to_truncate'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/truncation.rb:114:in `block in each_table'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:457:in `disable_referential_integrity'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/truncation.rb:113:in `each_table'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/deletion.rb:56:in `clean'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/base.rb:77:in `clean'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/configuration.rb:56:in `block in clean'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/configuration.rb:56:in `each'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/configuration.rb:56:in `clean'
      /Users/pma/Sites/app/features/support/env.rb:37:in `After'
http://127.0.0.1:55108/assets/tinymce/plugins/spellchecker/editor_plugin.js?3.4.5:1 SyntaxError: Parse error
fivetwentysix commented 13 years ago

Bare minimum repo https://github.com/PatrickMa/tiny_mce_rails_problems

bundle && cucumber

spohlenz commented 13 years ago

Can you try the latest version from git? I've added a release step to (hopefully) fix the encoding issues in the spellchecker plugin.

fivetwentysix commented 13 years ago

This week on batman:

So I'm using your git repository like this in my Gemfile:

gem 'tinymce-rails', :git => 'git://github.com/spohlenz/tinymce-rails.git'

But I'm still getting random fails, what makes this problem really frustrating is that it sometimes PASSES!

And it sometimes fails!

So I would run cucumber and everything seems okay one time, I'd push deploy, run cucumber again later that day to find it's broken! But none of my app code changed.

Feature: Payment object comments
  In order to explain a action I performed on a payment object
  As a user
  I want to make a comment

  @wip @javascript
  Scenario: Creating a comment                         # features/payment_objects/comments.feature:8
[paperclip] Saving attachments.
[paperclip] Saving attachments.
[paperclip] Saving attachments.
    Given I am in a company                            # features/step_definitions/application_steps.rb:1
    And I have created 1 cash requisitions             # features/step_definitions/payment_steps.rb:5
    When I am on the requisitions page                 # features/step_definitions/web_steps.rb:44
    And I click on the 1st requisition                 # features/step_definitions/payment_steps.rb:39
    When I open the Comments tab                       # features/step_definitions/payment_steps.rb:101
http://127.0.0.1:59193/assets/tinymce/plugins/fullscreen/editor_plugin.js?3.4.5:1 SyntaxError: Parse error
http://127.0.0.1:59193/assets/tinymce/plugins/spellchecker/editor_plugin.js?3.4.5:1 SyntaxError: Parse error
    When I fill in "comment_content" with "Testing123" # features/step_definitions/web_steps.rb:64http://127.0.0.1:59193/assets/tinymce/themes/advanced/editor_template.js?3.4.5:1 SyntaxError: Parse error

http://127.0.0.1:59193/assets/tinymce/langs/en.js?3.4.5:1 SyntaxError: Parse error
http://127.0.0.1:59193/assets/application.js:9506 TypeError: Result of expression 'q' [undefined] is not a constructor.
    And I click on "Comment"                           # features/step_definitions/web_steps.rb:52
    Then there should be a comment saying "Testing123" # features/step_definitions/payment_steps.rb:106
      PGError: ERROR:  relation "329" does not exist
      : ALTER TABLE "329" DISABLE TRIGGER ALL (ActiveRecord::StatementInvalid)
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:541:in `async_exec'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:541:in `block in execute'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:540:in `execute'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:455:in `disable_referential_integrity'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/truncation.rb:113:in `each_table'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/active_record/deletion.rb:56:in `clean'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/base.rb:77:in `clean'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/configuration.rb:56:in `block in clean'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/configuration.rb:56:in `each'
      /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/database_cleaner-0.6.7/lib/database_cleaner/configuration.rb:56:in `clean'
      /Users/pma/Sites/boss/features/support/env.rb:37:in `After'
http://127.0.0.1:59193/assets/tinymce/plugins/spellchecker/editor_plugin.js?3.4.5:1 SyntaxError: Parse error
fivetwentysix commented 13 years ago

Also, your git repository update did this:

[master][~/Sites/boss] git diff --color
diff --git a/Gemfile.lock b/Gemfile.lock
index 6868cbb..91f275d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,4 +1,12 @@
 GIT
+  remote: git://github.com/spohlenz/tinymce-rails.git
+  revision: e82ca9187b26322daf5e7fc9cda64ef258480d47
+  specs:
+    tinymce-rails (3.4.5)
+      digestion (~> 1.0)
+      railties (~> 3.1.0)
+
+GIT
   remote: git@github.com:PatrickMa/acts_as_audited.git
   revision: 409a8ac81e12c602e75f84bc0dd3f953a48c9bdf
   specs:
@@ -274,9 +282,6 @@ GEM
       libv8 (~> 3.3.10)
     thor (0.14.6)
     tilt (1.3.3)
-    tinymce-rails (3.4.5)
-      digestion (~> 1.0)
-      railties (~> 3.1.0)
     treetop (1.4.10)
       polyglot
       polyglot (>= 0.3.1)
@@ -332,7 +337,7 @@ DEPENDENCIES
   spork
   squeel
   therubyracer
-  tinymce-rails
+  tinymce-rails!
   turn
   uglifier
   warden

Which caused this:

Served asset /tinymce/plugins/spellchecker/editor_plugin.js - 404 Not Found (126ms)
spohlenz commented 13 years ago

Is your app working okay in development or production mode?

It's taking me a while to get capybara-webkit set up but I'm still looking into your test app.

fivetwentysix commented 13 years ago

Also getting these errors which prevents tinymce from even loading in development.

Started GET "/assets/tinymce/plugins/fullscreen/editor_plugin.js?3.4.5" for 127.0.0.1 at 2011-09-09 16:55:50 +0800
Served asset /tinymce/plugins/fullscreen/editor_plugin.js - 404 Not Found (4ms)

ActionController::RoutingError (No route matches [GET] "/assets/tinymce/plugins/fullscreen/editor_plugin.js"):

Rendered /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)

Started GET "/assets/tinymce/langs/en.js?3.4.5" for 127.0.0.1 at 2011-09-09 16:55:50 +0800
Served asset /tinymce/langs/en.js - 404 Not Found (7ms)

ActionController::RoutingError (No route matches [GET] "/assets/tinymce/langs/en.js"):

Rendered /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)

Started GET "/assets/tinymce/themes/advanced/editor_template.js?3.4.5" for 127.0.0.1 at 2011-09-09 16:55:50 +0800
Served asset /tinymce/themes/advanced/editor_template.js - 404 Not Found (4ms)

ActionController::RoutingError (No route matches [GET] "/assets/tinymce/themes/advanced/editor_template.js"):

Rendered /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)

Started GET "/assets/tinymce/plugins/spellchecker/editor_plugin.js?3.4.5" for 127.0.0.1 at 2011-09-09 16:55:50 +0800
Served asset /tinymce/plugins/spellchecker/editor_plugin.js - 404 Not Found (10ms)

ActionController::RoutingError (No route matches [GET] "/assets/tinymce/plugins/spellchecker/editor_plugin.js"):

Rendered /Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
spohlenz commented 13 years ago

Unfortunately I'm not seeing any of those issues in your test app. As far as the TinyMCE plugin is concerned, it works fine for me.

The cucumber feature doesn't actually pass (there should be a post with content "hello world" fails), but I believe that's due to the way TinyMCE creates an iframe for its content (and your feature is filling in the textarea). I'm not sure how to fix that though.

fivetwentysix commented 13 years ago

Yeah I was getting those errors in my actual app, it seems something happened. It works in production, not in development.

So I tried cloning my app again from when it was last working, but no hurrah.

jgarber commented 13 years ago

It's weird, isn't it? I get this error sometimes when running locally, sometimes when deploying to production (Heroku Cedar with asset compilation during slug compilation). I can't figure out why it sometimes works and sometimes fails.

frankel commented 13 years ago

I encountered the same problem, and i have to set config.serve_static_assets = true , but after using the master branch, the problem is solved. Thanks spohlenz !

jasonmarkperez commented 13 years ago

I believe I am having a similar issue with encoding. Everything works fine in development, even if i turn on sprocket compilation and precompile. But deploying to production I get something like this "rake aborted! 387: unexpected token at '", screenfulls of tinyMCE code, and then "(in /data/afar/shared/bundled_gems/ruby/1.9.1/gems/tinymce-rails-3.4.5/assets/precompiled/tinymce/tiny_mce_jquery_src.js)

Tasks: TOP => assets:precompile (See full trace by running task with --trace) rake aborted! "

and then it seems to happen again.

spohlenz commented 13 years ago

@PatrickMa, @jgarber, @jasonmarkperez can you try with different ruby versions and/or fresh gemsets? Make sure you're using the latest tinymce-rails from git though.

I'd really like to track down the source of these issues. Any insight you can gain from doing the above would be much appreciated.

jgarber commented 13 years ago

I experienced the problem intermittently before. Since updating to the latest tinymce-rails, I have not experienced it. At least for me, I think you fixed it! Great job!

Jason

On Sat, Sep 17, 2011 at 4:05 AM, Sam Pohlenz < reply@reply.github.com>wrote:

@PatrickMa, @jgarber, @jasonmarkperez can you try with different ruby versions and/or fresh gemsets? Make sure you're using the latest tinymce-rails from git though.

I'd really like to track down the source of these issues. Any insight you can gain from doing the above would be much appreciated.

Reply to this email directly or view it on GitHub: https://github.com/spohlenz/tinymce-rails/issues/10#issuecomment-2121447

gucki commented 12 years ago

I just encountered the same issue. Using tinymce-rails from master works. So https://github.com/spohlenz/tinymce-rails/commit/e82ca9187b26322daf5e7fc9cda64ef258480d47 seems to have fixed the issue. Would be great if you'd release a new gem soon :-)

lumpidu commented 11 years ago

Had the same issue, rails 3.2.8, Ruby-1.9.3 Got around, deleting the culprit characters in spellcheck plugin