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

Regex {Ps} symbol not supported #4360

Closed
abelsromero opened this issue Dec 5, 2016 · 7 comments
Closed

Regex {Ps} symbol not supported #4360

abelsromero opened this issue Dec 5, 2016 · 7 comments

Comments

@abelsromero
Copy link

abelsromero commented Dec 5, 2016

Environment

  • jRuby 1.7.26.
  • Running through maven-gem-plugin v 1.1.5.
  • Java 8.
  • Windows 7

Expected Behavior

The Ruby core documentation mentions support for \p{Ps} construct in 1.9.2 (https://ruby-doc.org/core-1.9.2/Regexp.html).
Since jRuby 1.7.x aims compatibility with Ruby 1.9.3 I would assume this construct is supported.
Note that in v 9.0.5.0 supports it.

Actual Behavior

However, when I run a this https://github.com/chloerei/asciidoctor-pdf-cjk/blob/v0.1.2/lib/asciidoctor/pdf/cjk.rb, I get the exception (RegexpError) invalid character property name <Ps>: /(?<!^|\p{Space}|\p{Ps}|\p{Pi})[\p{Han}\p{Hiragana}\p{Katakana}\p{Ps}\p{Pi}]/

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.asciidoctor:asciidoctor-maven-plugin:1.5.3:process-asciidoc (generate-pdf-doc) on project asciidoctor-pdf-example: Execution generate-pdf-doc of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.3:process-asciidoc failed: (SyntaxError) (RegexpError) invalid character property name <Ps>: /(?<!^|\p{Space}|\p{Ps}|\p{Pi})[\p{Han}\p{Hiragana}\p{Katakana}\p{Ps}\p{Pi}]/
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate-pdf-doc of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.3:process-asciidoc failed: (SyntaxError) (RegexpError) invalid character property name <Ps>: /(?<!^|\p{Space}|\p{Ps}|\p{Pi})[\p{Han}\p{Hiragana}\p{Katakana}\p{Ps}\p{Pi}]/
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        ... 20 more
Caused by: org.jruby.exceptions.RaiseException: (SyntaxError) (RegexpError) invalid character property name <Ps>: /(?<!^|\p{Space}|\p{Ps}|\p{Pi})[\p{Han}\p{Hiragana}\p{Katakana}\p{Ps}\p{Pi}]/
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1040)
        at RUBY.require(/C:/Users/asalgadr/.m2/repository/org/jruby/jruby-complete/1.7.26/jruby-complete-1.7.26.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54)
        at RUBY.(root)(C:/home/bin/.babun/cygwin/home/asalgadr/github/asciidoctor-maven-examples/asciidoctor-pdf-cjk-example/target/gems-provided/gems/asciidoctor-pdf-cjk-0.1.2/lib/asciidoctor-pdf-cjk.rb:1)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1040)
        at RUBY.(root)(/C:/Users/asalgadr/.m2/repository/org/jruby/jruby-complete/1.7.26/jruby-complete-1.7.26.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1)
        at RUBY.require(/C:/Users/asalgadr/.m2/repository/org/jruby/jruby-complete/1.7.26/jruby-complete-1.7.26.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:128)

I guess this is similar case as in #3603.

@olleolleolle
Copy link
Member

olleolleolle commented Dec 5, 2016

 ~ rvm use jruby-1.7.26
Using /Users/olle/.rvm/gems/jruby-1.7.26

Then I tried using the character properties one by one: the first one worked. (Update: this was a red herring. The wrong path to understand this.)

[1] pry(main)> /(\p{Space})/
=> /(\p{Space})/
[2] pry(main)> /(\p{Ps})/
SyntaxError: (RegexpError) invalid character property name <Ps>: /(\p{Ps})/
[2] pry(main)> /(\p{Pi})/
SyntaxError: (RegexpError) invalid character property name <Pi>: /(\p{Pi})/
[2] pry(main)> /(\p{Han})/
SyntaxError: (RegexpError) invalid character property name <Han>: /(\p{Han})/
[2] pry(main)> /(\p{Hiragana})/
SyntaxError: (RegexpError) invalid character property name <Hiragana>: /(\p{Hiragana})/
[2] pry(main)> /(\p{Katakana})/
SyntaxError: (RegexpError) invalid character property name <Katakana>: /(\p{Katakana})/

@olleolleolle
Copy link
Member

@abelsromero Can you check if adding # encoding: utf-8 at the top of the file cjk.rb would change things?

@olleolleolle
Copy link
Member

olleolleolle commented Dec 5, 2016

(I was able to use the Hiragana character group without failing in a this small program:

# encoding: utf-8

if "~" =~ /(\p{Hiragana})+$/
  puts "match"
end

Calling it:

 ~ ruby -v re.rb
jruby 1.7.26 (1.9.3p551) 2016-08-26 69763b8 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_92-b14 +jit [darwin-x86_64]

No output, since my non-hiragana string didn't match. But no error either.

The program fails with the error when I had no encoding marker at the first line.

@abelsromero
Copy link
Author

@abelsromero Can you check if adding # encoding: utf-8 at the top of the file cjk.rb would change things?

👍 worked perfectly on JRuby 1.7.26, 9.0.5.0 and native Ruby 2.3.1! Thanks a lot @olleolleolle.
I will push this to the original repo, however and to avoid waiting for a release. Do you know if there's a way to force jRuby to read the file properly?

@olleolleolle
Copy link
Member

@abelsromero I was about to say I don't know, and then I ran a search for "encoding" in the wiki of this repo, and found - https://github.com/jruby/jruby/wiki/JRubyCommandLineParameters Where the word comes up. Can you try a few of those?

@abelsromero
Copy link
Author

Thanks for the tip, really, but I since I am invoking jRuby through maven and a third Java API I'd need to promote those changes to a few layers. I also checked this https://github.com/jruby/jruby/wiki/ConfiguringJRuby, but needs users to set up the file locally :/

Luckily, you saw there's a patch on the go, so probably everything will be fixed soon :)
I am happy with it, I'll be closing the issue.

@olleolleolle
Copy link
Member

@abelsromero Thanks for checking!

@enebo enebo added this to the Invalid or Duplicate milestone Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants