Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit b22247d

Browse files
committed
Merge pull request #167 from cowboyd/path-escaping
Escape the library and include paths
2 parents 4f41132 + 23b3a53 commit b22247d

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

ext/libv8/paths.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
require 'rbconfig'
2+
require 'shellwords'
23
require File.expand_path '../arch', __FILE__
34

45
module Libv8
56
module Paths
67
module_function
78

89
def include_paths
9-
["#{vendored_source_path}/include"]
10+
[Shellwords.escape("#{vendored_source_path}/include")]
1011
end
1112

1213
def object_paths
13-
[libv8_object(:base), libv8_object(:snapshot)]
14+
[libv8_object(:base), libv8_object(:snapshot)].map do |path|
15+
Shellwords.escape path
16+
end
1417
end
1518

1619
def config

spec/location_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@
5454
@context.stub(:incflags) {@incflags ||= "-I/usr/include -I/usr/local/include"}
5555
@context.stub(:ldflags) {@ldflags ||= "-lobjc -lpthread"}
5656

57-
Libv8::Paths.stub(:include_paths) {["/frp/v8/include"]}
58-
Libv8::Paths.stub(:object_paths) {["/frp/v8/obj/libv8_base.a", "/frp/v8/obj/libv8_snapshot.a"]}
57+
Libv8::Paths.stub(:vendored_source_path) {"/foo bar/v8"}
58+
Libv8::Arch.stub(:libv8_arch) {'x64'}
5959
@location.configure @context
6060
end
6161

6262
it "prepends its own incflags before any pre-existing ones" do
63-
@context.incflags.should eql "-I/frp/v8/include -I/usr/include -I/usr/local/include"
63+
@context.incflags.should eql "-I/foo\\ bar/v8/include -I/usr/include -I/usr/local/include"
6464
end
6565

6666
it "prepends the locations of any libv8 objects on the the ldflags" do
67-
@context.ldflags.should eql "/frp/v8/obj/libv8_base.a /frp/v8/obj/libv8_snapshot.a -lobjc -lpthread"
67+
@context.ldflags.should eql "/foo\\ bar/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a /foo\\ bar/v8/out/x64.release/obj.target/tools/gyp/libv8_snapshot.a -lobjc -lpthread"
6868
end
6969
end
7070
end

0 commit comments

Comments
 (0)