xelkano / redmine_xapian

This plugin allows searches across attachments with xapian search engine
GNU General Public License v2.0
54 stars 26 forks source link

JSON::ParserError (859: unexpected token at #141

Closed keineahnung2345 closed 1 year ago

keineahnung2345 commented 1 year ago

In devel branch, I have to revert the change in https://github.com/xelkano/redmine_xapian/commit/15e120845b0f3865b636cd3bdb17bf8ee4dd97d5 a.k.a: change attributes = JSON.parse(value.gsub(/:([a-zA-z]+)/, '"\\1"').gsub('=>', ': ')).symbolize_keys to attributes = eval value to get rid of JSON::ParserError.

picman commented 1 year ago

eval is not acceptable. What is the error? Cannot be changed the REGEXP to fix the error?

keineahnung2345 commented 1 year ago

The remaining part of the error message is just the json file. Maybe this error happens because my file is in Chinese.

picman commented 1 year ago

Post the file, I will try it.

picman commented 1 year ago

I have tried to index a file with some Chinese words and it worked fine: image

keineahnung2345 commented 1 year ago

Thank you. I've also found that it works for my other Chinese files. But that file is somehow credential, I'll check what's wrong myself.

keineahnung2345 commented 1 year ago

After applying the PR above, there's still another problem for my Chinese docx file, attributes[:filename] should be 客戶.docx, but it will be shown as xE5xAExA2xE6x88xB6.docx. It seems JSON.parse eats the backslashes. Also attributes[:url] is affected so the links shown are invalid.

picman commented 1 year ago

I believe, that I've fixed most of the reported problems:

  1. Filenames are parsed correctly.
  2. The URL is correct even for repositories without identifiers.
  3. xapian-ruby gem added to the Gemfile
keineahnung2345 commented 1 year ago

Yes, the instance_eval works like a charm.