Closed disjunctor closed 9 years ago
Can be dirty-fixed by two force-encoding patches one in dav4rack gem
diff --git a/resource.rb.bak b/resource.rb
index 4f3e57f..3b6957a 100644
--- a/resource.rb.bak
+++ b/resource.rb
@@ -381,7 +381,7 @@ module DAV4Rack
# Create a new child with the given name
# NOTE:: Include trailing '/' if child is collection
def child(name)
- new_public = public_path.dup
+ new_public = public_path.dup.force_encoding("utf-8")
new_public = new_public + '/' unless new_public[-1,1] == '/'
new_public = '/' + new_public unless new_public[0,1] == '/'
new_path = path.dup
and one in plugin
diff --git a/lib/redmine_dmsf/webdav/base_resource.rb b/lib/redmine_dmsf/webdav/base_resource.rb
index 5340c22..74a39d9 100644
--- a/lib/redmine_dmsf/webdav/base_resource.rb
+++ b/lib/redmine_dmsf/webdav/base_resource.rb
@@ -66,6 +66,7 @@ module RedmineDmsf
'',
'',
] + entities unless parent.nil?
+ entities.force_encoding('utf-8')
@response.body << index_page % [ path.empty? ? "/" : path, path.empty? ? "/" : path , entities ]
end
The problem come from
bundler/ruby/2.0.0/gems/dav4rack-0.2.11/lib/dav4rack/handler.rb:20
request = Rack::Request.new(env)
after that request.path contains string in Encoding:ASCII-8BIT, when actual data is utf8-path. Inresting that when path contains no utf-8 data this string marked as Encoding:UTF-8
gem rack-utf8_sanitizer also helps
I have similar problem. we have error, when we try to open folders, which have russian names.
Above mentioned tips not helped us.
Same problem while trying to upload via WebDAV files with spanish characters like ó, í, ñ, etc.
Fixed. Tested with Czech characters: 'Žlutý'. It works as expected.
Have Chinese chars in file/folder name, still failed with the same issue.
Do you use 1.5.1-devel?
Can you post a file/folder name in Chinese, that causes problems?
Thanks for your reply. Yes. I have the latest 1.5.1-stable branch.
Environment: Redmine version 2.6.3.stable Ruby version 2.1.5-p273 (2014-11-13) [x86_64-linux] Rails version 3.2.21 Environment production Database adapter Mysql2 SCM: Subversion 1.6.11 Mercurial 1.4 Bazaar 2.1.1 Git 1.7.1 Filesystem Redmine plugins: redmine_dmsf 1.5.1 stable
The the following url causes 500 internal error, that is: http://myserver:9090/dmsf/webdav/test/%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86
What strange is, there is a file with a Chinese name under the above url/folder which can be OPENED correctly, the link is : http://myserver:9090/dmsf/webdav/test/%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86/Web%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91%E5%B7%A5%E7%A8%8B%E5%B8%88%E6%8A%80%E8%83%BD.pdf
So the problem might be the index page of the first URL can not be rendered?
Here is the log file:
Connecting to database specified by database.yml Creating scope :sorted. Overwriting existing method User.sorted. Creating scope :sorted. Overwriting existing method Group.sorted. Creating scope :system. Overwriting existing method Enumeration.system. Starting Time Tracker plugin for RedMine [1m[36mUserCustomField Load (0.5ms)[0m [1mSELECT `custom_fields`.* FROM `custom_fields` WHERE `custom_fields`.`type` IN ('UserCustomField') AND `custom_fields`.`name` = 'Ultraviolet Theme' LIMIT 1[0m Started GET "/dmsf/webdav/test/%e9%a1%b9%e7%9b%ae%e7%ae%a1%e7%90%86" for ssssss at 2015-04-02 13:06:22 +0800 [1m[35mSetting Load (0.4ms)[0m SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'plugin_redmine_dmsf' LIMIT 1 [1m[36mUser Load (0.4ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`login` = 'xxxx'[0m [1m[35mSQL (2.6ms)[0m UPDATE `users` SET `last_login_on` = '2015-04-02 13:06:22' WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` = 7 [1m[36mProject Load (0.3ms)[0m [1mSELECT `projects`.* FROM `projects` WHERE `projects`.`identifier` = 'test' LIMIT 1[0m [1m[35mEnabledModule Load (0.4ms)[0m SELECT `enabled_modules`.* FROM `enabled_modules` WHERE `enabled_modules`.`project_id` = 1 [1m[36mDmsfFolder Load (0.5ms)[0m [1mSELECT `dmsf_folders`.* FROM `dmsf_folders` WHERE `dmsf_folders`.`deleted` = 0 AND `dmsf_folders`.`project_id` = 1 AND `dmsf_folders`.`title` = '项目管理' ORDER BY title ASC[0m [1m[35mDmsfFolder Load (0.3ms)[0m SELECT `dmsf_folders`.* FROM `dmsf_folders` WHERE `dmsf_folders`.`dmsf_folder_id` = 11 [1m[36mDmsfFile Load (0.3ms)[0m [1mSELECT `dmsf_files`.* FROM `dmsf_files` WHERE `dmsf_files`.`dmsf_folder_id` = 11 AND `dmsf_files`.`deleted` = 0[0m Encoding::CompatibilityError (incompatible character encodings: ASCII-8BIT and UTF-8): dav4rack (0.3.0) lib/dav4rack/resource.rb:406:in `child' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/base_resource.rb:85:in `child' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/dmsf_resource.rb:61:in `block in children' activerecord (3.2.21) lib/active_record/relation/delegation.rb:6:in `map' activerecord (3.2.21) lib/active_record/relation/delegation.rb:6:in `map' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/dmsf_resource.rb:60:in `children' dav4rack (0.3.0) lib/dav4rack/resource.rb:116:in `method_missing' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/base_resource.rb:64:in `html_display' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/dmsf_resource.rb:202:in `get' dav4rack (0.3.0) lib/dav4rack/resource.rb:116:in `method_missing' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/resource_proxy.rb:99:in `get' dav4rack (0.3.0) lib/dav4rack/resource.rb:116:in `method_missing' dav4rack (0.3.0) lib/dav4rack/controller.rb:78:in `get' dav4rack (0.3.0) lib/dav4rack/handler.rb:30:in `call' journey (1.0.4) lib/journey/router.rb:68:in `block in call' journey (1.0.4) lib/journey/router.rb:56:in `each' journey (1.0.4) lib/journey/router.rb:56:in `call' actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:608:in `call' rack-openid (1.4.2) lib/rack/openid.rb:98:in `call' request_store (1.0.5) lib/request_store/middleware.rb:9:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' rack (1.4.5) lib/rack/etag.rb:23:in `call' rack (1.4.5) lib/rack/conditionalget.rb:25:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/head.rb:14:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/params_parser.rb:21:in `call' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/no_parse.rb:33:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/flash.rb:242:in `call' rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context' rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/cookies.rb:341:in `call' activerecord (3.2.21) lib/active_record/query_cache.rb:64:in `call' activerecord (3.2.21) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `_run__1925844483086144649__call__3523164737377064723__callbacks' activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.21) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' activesupport (3.2.21) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' railties (3.2.21) lib/rails/rack/logger.rb:32:in `call_app' railties (3.2.21) lib/rails/rack/logger.rb:18:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/request_id.rb:22:in `call' rack (1.4.5) lib/rack/methodoverride.rb:21:in `call' rack (1.4.5) lib/rack/runtime.rb:17:in `call' activesupport (3.2.21) lib/active_support/cache/strategy/local_cache.rb:72:in `call' rack (1.4.5) lib/rack/lock.rb:15:in `call' actionpack (3.2.21) lib/action_dispatch/middleware/static.rb:83:in `call' rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward' rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch' rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup' rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!' rack-cache (1.2) lib/rack/cache/context.rb:51:in `call' railties (3.2.21) lib/rails/engine.rb:484:in `call' railties (3.2.21) lib/rails/application.rb:231:in `call' railties (3.2.21) lib/rails/railtie/configurable.rb:30:in `method_missing' passenger (5.0.1) lib/phusion_passenger/rack/thread_handler_extension.rb:85:in `process_request' passenger (5.0.1) lib/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request' passenger (5.0.1) lib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop' passenger (5.0.1) lib/phusion_passenger/request_handler.rb:414:in `block (3 levels) in start_threads' passenger (5.0.1) lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
The line 406 in dav4rack (0.3.0) lib/dav4rack/resource.rb is: self.class.new("#{new_public}#{name}", "#{new_path}#{name}", request, response, options.merge(:user => @user))
Fixed.
Thanks for the fix! But in master branch, the line 81 (if parent?) in lib/redmine_dmsf/webdav/base_resource.rb seems to cause recession in my site. The original removal line 79 (unless parent.nil?) just works after changing back.
Log error:
... NoMethodError (Undefined method: parent? for class #<RedmineDmsf::Webdav::ProjectResource:0x007fe0bd206160>.): dav4rack (0.3.0) lib/dav4rack/resource.rb:114:in `method_missing' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/base_resource.rb:81:in `html_display' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/project_resource.rb:87:in `get' ...
Got an new error after applying the new change :s
NoMethodError (Undefined method: parent? for class < RedmineDmsf::Webdav::IndexResource:0x007f16615371a8 >.): dav4rack (0.3.0) lib/dav4rack/resource.rb:114:in `method_missing' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/base_resource.rb:81:in `html_display' plugins/redmine_dmsf/lib/redmine_dmsf/webdav/index_resource.rb:79:in `get'
Thanks for your quick fix! It works!
When accessing webdav with browser the log contains: