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

Disable unicode_strings when working with regular expressions #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Mango/BSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ sub _decode_value {
my ($p, $m) = (_decode_cstring($bsonref), _decode_cstring($bsonref));
croak "invalid regex modifier(s) in 'qr/$p/$m'"
if length($m) and $m !~ /^[msixpadlun]+\z/;
# prevent from injecting qr//u modifier implied by a feature enabled by
# Mojolicious 8.50
no feature 'unicode_strings';
# escape $pat to avoid code injection
return eval "qr/\$p/$m";
}
Expand Down
3 changes: 3 additions & 0 deletions t/bson.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ sub TO_BSON { {something => shift->something} }

package main;
use Mojo::Base -strict;
# prevent from injecting qr//u modifier implied by a feature enabled by
# Mojolicious 8.50
no feature 'unicode_strings';
no warnings 'portable'; # Mango works on 64bits systems only

use Test::More;
Expand Down