WebKit Bugzilla
Attachment 359574 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 for landing
bug-193420-20190118185755.patch (text/plain), 5.52 KB, created by
Keith Miller
on 2019-01-18 18:57:56 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Keith Miller
Created:
2019-01-18 18:57:56 PST
Size:
5.52 KB
patch
obsolete
>Subversion Revision: 239933 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index d0a583274b0d8f1979e433901a4eeb0021d49967..4bd39b14649ec0321175f3f8b5ad098f3ee0594d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,21 @@ >+2019-01-18 Keith Miller <keith_miller@apple.com> >+ >+ JSScript API should only take ascii files. >+ https://bugs.webkit.org/show_bug.cgi?id=193420 >+ >+ Reviewed by Saam Barati. >+ >+ This patch leaves the UTF8 method for binary compatablity, which >+ will be removed later. >+ >+ * API/JSScript.h: >+ * API/JSScript.mm: >+ (fillBufferWithContentsOfFile): >+ (+[JSScript scriptFromASCIIFile:inVirtualMachine:withCodeSigning:andBytecodeCache:]): >+ (+[JSScript scriptFromUTF8File:inVirtualMachine:withCodeSigning:andBytecodeCache:]): >+ * 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..8ded7ca770efc1b871db04f245db5531c617d4e1 100644 >--- a/Source/JavaScriptCore/API/JSScript.h >+++ b/Source/JavaScriptCore/API/JSScript.h >@@ -52,6 +52,14 @@ 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)scriptFromASCIIFile:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(nullable NSURL *)codeSigningPath andBytecodeCache:(nullable NSURL *)cachePath; >+ >+ >+/*! >+ This is deprecated and is equivalent to scriptFromASCIIFile:inVirtualMachine:withCodeSigning:andBytecodeCache:. > */ > + (nullable instancetype)scriptFromUTF8File:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(nullable NSURL *)codeSigningPath andBytecodeCache:(nullable NSURL *)cachePath; > >diff --git a/Source/JavaScriptCore/API/JSScript.mm b/Source/JavaScriptCore/API/JSScript.mm >index 796c41ef9ecc39847006cfb1b6573c5349d3fddd..f7e939af098bf5d0f53ed1e8b32d75a4d823fd7f 100644 >--- a/Source/JavaScriptCore/API/JSScript.mm >+++ b/Source/JavaScriptCore/API/JSScript.mm >@@ -62,7 +62,7 @@ static bool fillBufferWithContentsOfFile(FILE* file, Vector& buffer) > return readSize == buffer.size() - initialSize; > } > >-static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& buffer) >+static bool fillBufferWithContentsOfFile(const String& fileName, Vector<LChar>& buffer) > { > FILE* f = fopen(fileName.utf8().data(), "rb"); > if (!f) { >@@ -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); >@@ -88,15 +88,23 @@ static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& b > if (!filePathURL.isLocalFile()) > return nil; > // FIXME: This should mmap the contents of the file instead of copying it into dirty memory. >- Vector<char> buffer; >+ Vector<LChar> buffer; > if (!fillBufferWithContentsOfFile(filePathURL.fileSystemPath(), buffer)) > return nil; > >+ if (!charactersAreAllASCII(buffer.data(), buffer.size())) >+ return nil; >+ > JSScript *result = [[JSScript alloc] init]; > result->m_source = String::fromUTF8WithLatin1Fallback(buffer.data(), buffer.size()); > return result; > } > >++ (instancetype)scriptFromUTF8File:(NSURL *)filePath inVirtualMachine:(JSVirtualMachine *)vm withCodeSigning:(NSURL *)codeSigningPath andBytecodeCache:(NSURL *)cachePath >+{ >+ return [JSScript scriptFromASCIIFile:filePath inVirtualMachine:vm withCodeSigning:codeSigningPath andBytecodeCache:cachePath]; >+} >+ > const String& getJSScriptSourceCode(JSScript *module) { return module->m_source; } > > @end >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