Fixes #5377 : Split packager on single @ regardless of escaped @@s. (#5379)

This commit is contained in:
Kenneth Perry 2017-07-12 18:06:01 -05:00 коммит произвёл Alon Zakai
Родитель e609f50e30
Коммит 09251bcaf9
3 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -300,3 +300,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Nikolay Zapolnov <zapolnov@gmail.com>
* Nazar Mokrynskyi <nazar@mokrynskyi.com>
* Yury Delendik <ydelendik@mozilla.com> (copyright owned by Mozilla Foundation)
* Kenneth Perry <thothonegan@gmail.com>

Просмотреть файл

@ -138,6 +138,9 @@ If manually bisecting:
absolute_src_path2 = os.path.join(self.get_dir(), '.somefile.txt').replace('\\', '/')
open(absolute_src_path2, 'w').write('''load me right before running the code please''')
absolute_src_path3 = os.path.join(self.get_dir(), 'some@file.txt').replace('\\', '/')
open(absolute_src_path3, 'w').write('''load me right before running the code please''')
def make_main(path):
print 'make main at', path
path = path.replace('\\', '\\\\').replace('"', '\\"') # Escape tricky path name for use inside a C string.
@ -174,7 +177,9 @@ If manually bisecting:
(absolute_src_path + "@/", "somefile.txt"),
("somefile.txt@/directory/file.txt", "/directory/file.txt"),
("somefile.txt@/directory/file.txt", "directory/file.txt"),
(absolute_src_path + "@/directory/file.txt", "directory/file.txt")]
(absolute_src_path + "@/directory/file.txt", "directory/file.txt"),
("some@@file.txt@other.txt", "other.txt"),
("some@@file.txt@some@@otherfile.txt", "some@otherfile.txt")]
for test in test_cases:
(srcpath, dstpath) = test

Просмотреть файл

@ -164,12 +164,14 @@ for arg in sys.argv[2:]:
leading = ''
elif leading == 'preload' or leading == 'embed':
mode = leading
uses_at_notation = '@' in arg.replace('@@', '') # '@@' in input string means there is an actual @ character, a single '@' means the 'src@dst' notation.
arg = arg.replace('@@', '@')
at_position = arg.replace('@@', '__').find('@') # position of @ if we're doing 'src@dst'. '__' is used to keep the index same with the original if they escaped with '@@'.
uses_at_notation = (at_position != -1) # '@@' in input string means there is an actual @ character, a single '@' means the 'src@dst' notation.
if uses_at_notation:
srcpath, dstpath = arg.split('@') # User is specifying destination filename explicitly.
srcpath = arg[0:at_position].replace('@@', '@') # split around the @
dstpath = arg[at_position+1:].replace('@@', '@')
else:
srcpath = dstpath = arg # Use source path as destination path.
srcpath = dstpath = arg.replace('@@', '@') # Use source path as destination path.
if os.path.isfile(srcpath) or os.path.isdir(srcpath):
data_files.append({ 'srcpath': srcpath, 'dstpath': dstpath, 'mode': mode, 'explicit_dst_path': uses_at_notation })
else: