[Eval] Preserve hashref results for decoded Unicode config source

Ouverte
#2,228 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
38/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java, perl
Domaine
compilers

Piste de recherche

Start by tracing string eval result handling in PerlOnJava and identify the project’s regression test entry point for eval behavior; compare the decoded Unicode reproducer under system Perl, JVM, and interpreter backends. Done means project-owned coverage passes on both backends and the RoutesConfig 0.07 t/basic.t suite completes successfully.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area:parser area:runtime area:unicode bug

Summary

Mojolicious::Plugin::Config evaluates UTF-8-decoded configuration source and expects the source's outer hash expression to return a hash reference. With a nested route group containing four route descriptions, PerlOnJava's string eval returns the nested array reference instead. Mojolicious::Plugin::Config::parse then dies because the result is not a hash reference.

This is reproducible on both PerlOnJava backends and passes on standard Perl. The failure is in dynamic eval's result for the decoded config source, not in the CPAN harness or a missing prerequisite.

CPAN evidence

  • Distribution: Mojolicious-Plugin-RoutesConfig 0.07; runtime prerequisite Mojolicious >= 9.17.
  • CPAN random tester run: 20261129-192130-74689.
  • Failing test: t/basic.t; it prints its first passing assertion, then exits 255 before completing TAP.
  • System Perl 5.42.2 with Mojolicious 9.49: all 23 tests across five files pass; the three author tests are skipped.
  • PerlOnJava at cce9dbe100157df64836677c95a50775bc53ac80, with Mojolicious 9.49: t/basic.t fails on both JVM and interpreter. The config loader reports that complex_routes.conf did not return a hash reference.
  • The distribution is pure Perl and does not require a native dependency for this test.

With JPERL_EVAL_TRACE=1, the config eval completes without a syntax error, but its result is reported as RuntimeList with scalar value ARRAY(...). The corresponding system Perl result is a hash reference.

Reproducer

This follows the config-loading pattern in Mojolicious::Plugin::Config::parse. The route source is encoded and decoded so the eval receives a UTF-8-decoded string, as it does when loading the CPAN fixture.

use utf8;
use Encode qw(encode);
use Mojo::Util qw(decode);

my $octets = encode('UTF-8', <<'CONFIG');
{ routes => [{
    under => {
      '/управление' => sub {
        my $c = shift;
        return 1 if $c->current_route('login') || $c->user;
        $c->redirect_to('login');
        return;
      },
    },
    routes => [
      { any => '/blah/:id', to => {controller => 'Blah', action => 'index'} },
      { get => '/вход', to => 'Login#index' },
      { post => '/вход', to => 'Login#index' },
      { any => '/lbah/:id', to => {controller => 'Lbah', action => 'index'} },
    ],
}] };
CONFIG
my $content = decode('UTF-8', $octets);
my $code = 'package Mojolicious::Plugin::Config::Sandbox; no warnings;'
  . 'sub app; local *app = sub {}; use Mojo::Base -strict; ' . $content;
my $config = eval $code;
die $@ if $@;
die 'expected HASH, got ' . (ref($config) || 'SCALAR')
  unless ref($config) eq 'HASH';

System Perl evaluates this to HASH. PerlOnJava JVM and interpreter evaluate it to ARRAY.

Expected behavior

A scalar-context string eval of this configuration source should return the outer hash reference on both PerlOnJava backends, matching system Perl. The existing RoutesConfig upstream suite should then complete successfully.

Acceptance criteria

  • Add project-owned regression coverage for the decoded Unicode config eval and validate its expected behavior with system Perl first.
  • Pass the regression on both JVM and interpreter backends.
  • Run Mojolicious::Plugin::RoutesConfig 0.07 t/basic.t and confirm the upstream suite passes on PerlOnJava.
Langage dominant
Perl
Étoiles
67
Forks
9
Merge moyen
6 h 45 min
PR mergées (30 j)
104

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de fglock/PerlOnJava

Toutes les issues de fglock/PerlOnJava

Issues similaires

Plus d'issues Perl

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.