WebKit Bugzilla
Attachment 359101 Details for
Bug 193420
: JSScript API should only take ascii files.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193420-20190114171401.patch (text/plain), 4.28 KB, created by
Keith Miller
on 2019-01-14 17:14:03 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Keith Miller
Created:
2019-01-14 17:14:03 PST
Size:
4.28 KB
patch
obsolete
>Subversion Revision: 239933 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index d0a583274b0d8f1979e433901a4eeb0021d49967..695c02b023ac1317b526770bd6d7c38319166492 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,17 @@ >+2019-01-14 Keith Miller <keith_miller@apple.com> >+ >+ JSScript API should only take ascii files. >+ https://bugs.webkit.org/show_bug.cgi?id=193420 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * API/JSScript.h: >+ * API/JSScript.mm: >+ (+[JSScript scriptFromASCIIFile:inVirtualMachine:withCodeSigning:andBytecodeCache:]): >+ (+[JSScript scriptFromUTF8File:inVirtualMachine:withCodeSigning:andBytecodeCache:]): Deleted. >+ * API/tests/testapi.mm: >+ (-[JSContextFileLoaderDelegate context:fetchModuleForIdentifier:withResolveHandler:andRejectHandler:]): >+ > 2019-01-14 Keith Miller <keith_miller@apple.com> > > JSC should have a module loader API >diff --git a/Source/JavaScriptCore/API/JSScript.h b/Source/JavaScriptCore/API/JSScript.h >index 90cb609088ec82f744aa72a7cd7c1d8e13853c87..87570e30052aad1c6631a16d69d82bcb90594e31 100644 >--- a/Source/JavaScriptCore/API/JSScript.h >+++ b/Source/JavaScriptCore/API/JSScript.h >@@ -52,8 +52,10 @@ JSC_CLASS_AVAILABLE(macosx(JSC_MAC_TBA), ios(JSC_IOS_TBA)) > @param cachePath A URL containing the path where the VM should cache for future execution. > @result The new script. > @discussion the files at filePath, codeSigningPath, and cachePath should not be externally modified for the lifecycle of vm. Note that codeSigningPath and cachePath are not used currently, but that will change in the near future. >+ >+ If the file at filePath is not ascii this method will return nil. > */ >-+ (nullable instancetype)scriptFromUTF8File:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(nullable NSURL *)codeSigningPath andBytecodeCache:(nullable NSURL *)cachePath; >++ (nullable instancetype)scriptFromASCIIFile:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(nullable NSURL *)codeSigningPath andBytecodeCache:(nullable NSURL *)cachePath; > > @end > >diff --git a/Source/JavaScriptCore/API/JSScript.mm b/Source/JavaScriptCore/API/JSScript.mm >index 796c41ef9ecc39847006cfb1b6573c5349d3fddd..ad2c6c5e2d1c8b10b97516f13d5f1bb5b58d86f9 100644 >--- a/Source/JavaScriptCore/API/JSScript.mm >+++ b/Source/JavaScriptCore/API/JSScript.mm >@@ -77,7 +77,7 @@ static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& b > } > > >-+ (instancetype)scriptFromUTF8File:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(NSURL *)codeSigningPath andBytecodeCache:(NSURL *)cachePath >++ (instancetype)scriptFromASCIIFile:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(NSURL *)codeSigningPath andBytecodeCache:(NSURL *)cachePath > { > // FIXME: This should check codeSigning. > UNUSED_PARAM(codeSigningPath); >@@ -92,6 +92,11 @@ static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& b > if (!fillBufferWithContentsOfFile(filePathURL.fileSystemPath(), buffer)) > return nil; > >+ for (char c : buffer) { >+ if (!isASCII(c)) >+ return nil; >+ } >+ > JSScript *result = [[JSScript alloc] init]; > result->m_source = String::fromUTF8WithLatin1Fallback(buffer.data(), buffer.size()); > return result; >diff --git a/Source/JavaScriptCore/API/tests/testapi.mm b/Source/JavaScriptCore/API/tests/testapi.mm >index 435fdbb36d2446e85db5313633cd764fef7998b0..13beb69f2bcd72194c70af568f9612d61ef6acc3 100644 >--- a/Source/JavaScriptCore/API/tests/testapi.mm >+++ b/Source/JavaScriptCore/API/tests/testapi.mm >@@ -2017,7 +2017,7 @@ static NSURL *resolvePathToScripts() > - (void)context:(JSContext *)context fetchModuleForIdentifier:(JSValue *)identifier withResolveHandler:(JSValue *)resolve andRejectHandler:(JSValue *)reject > { > NSURL *filePath = [NSURL URLWithString:[identifier toString]]; >- auto *script = [JSScript scriptFromUTF8File:filePath inVirtualMachine:[context virtualMachine] withCodeSigning:nil andBytecodeCache:nil]; >+ auto *script = [JSScript scriptFromASCIIFile:filePath inVirtualMachine:[context virtualMachine] withCodeSigning:nil andBytecodeCache:nil]; > if (script) > [resolve callWithArguments:@[script]]; > else
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193420
:
359101
|
359574