Closed Bug 1442242 Opened 7 years ago Closed 7 years ago

Make the constructos of URI implementations private

Categories

(Core :: Networking, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox60 --- wontfix
firefox61 --- fixed

People

(Reporter: valentin, Assigned: valentin)

References

Details

(Whiteboard: [necko-triaged])

Attachments

(3 files)

Not allowing code to directly instantiate the URI implementations will help with ensuring that no mutation is possible, and that URIs are always in a defined state when returned by the mutators.
Comment on attachment 8957171 [details] Bug 1442242 - Add nsIURIMutator method to mark when the URI implementation should support nsIFileURL https://reviewboard.mozilla.org/r/226112/#review234256 ::: netwerk/base/nsStandardURL.h:467 (Diff revision 1) > mutator.forget(aMutator); > } > return BaseURIMutator<T>::mURI->SetFileExtensionInternal(aFileExtension); > } > > + virtual T* Create() override nit: we should not use virtual and override together anymore ::: netwerk/protocol/file/nsFileProtocolHandler.cpp:259 (Diff revision 1) > nsFileProtocolHandler::NewFileURIMutator(nsIFile *aFile, nsIURIMutator **aResult) > { > NS_ENSURE_ARG_POINTER(aFile); > nsresult rv; > > - nsCOMPtr<nsIURI> url = new nsStandardURL(true); > + nsCOMPtr<nsIURIMutator> mutator = new nsStandardURL::Mutator(); was the |true| argument lost here? ::: netwerk/protocol/res/SubstitutingProtocolHandler.h:140 (Diff revision 1) > public: > explicit Mutator() = default; > private: > virtual ~Mutator() = default; > + > + virtual SubstitutingURL* Create() override again, remove virtual
Attachment #8957171 - Flags: review?(honzab.moz) → review-
Comment on attachment 8957172 [details] Bug 1442242 - Make the constructor of nsJARURI private https://reviewboard.mozilla.org/r/226114/#review234260 ::: modules/libjar/nsIJARURI.idl:44 (Diff revision 1) > + > +[builtinclass, uuid(d66df117-eda7-4324-b4e4-1f670ff6718e)] > +interface nsIJARURIMutator : nsISupports > +{ > + void setSpecBaseCharset(in AUTF8String aSpec, in nsIURI aBase, in string aCharset); > +}; comments on any new interface please
Attachment #8957172 - Flags: review?(honzab.moz) → review+
Comment on attachment 8957173 [details] Bug 1442242 - Make the constuctors of URI implementations private https://reviewboard.mozilla.org/r/226116/#review234310 ::: netwerk/base/nsSimpleNestedURI.h:34 (Diff revision 1) > class nsSimpleNestedURI : public nsSimpleURI, > public nsINestedURI > { > protected: > - ~nsSimpleNestedURI() {} > - > + ~nsSimpleNestedURI() = default; > + nsSimpleNestedURI() = default; ctor first? ::: widget/tests/unit/test_taskbar_jumplistitems.js (Diff revision 1) > Assert.equal(link.uriHash, "iSx6UH1a9enVPzUA9JZ42g=="); > - > - var uri3 = Cc["@mozilla.org/network/simple-uri;1"] > - .createInstance(Ci.nsIURI); > - link.uri = uri3; > - Assert.equal(link.uriHash, "hTrpDwNRMkvXPqYV5kh1Fw=="); why this removal?
Attachment #8957173 - Flags: review?(honzab.moz) → review+
Comment on attachment 8957171 [details] Bug 1442242 - Add nsIURIMutator method to mark when the URI implementation should support nsIFileURL https://reviewboard.mozilla.org/r/226112/#review234256 > was the |true| argument lost here? It wasn't needed. Calling nsStandardURL::Mutator::SetFile will create a new nsStandardURL(true)
Comment on attachment 8957173 [details] Bug 1442242 - Make the constuctors of URI implementations private https://reviewboard.mozilla.org/r/226116/#review234310 > why this removal? This computes the hash of an uninitialized instance of nsSimpleURI. We don't allow that anymore.
Comment on attachment 8957171 [details] Bug 1442242 - Add nsIURIMutator method to mark when the URI implementation should support nsIFileURL https://reviewboard.mozilla.org/r/226112/#review234678 should we mark some of the mutator classes as final? (not in this bug, probably) ::: netwerk/base/nsIFileURL.idl:33 (Diff revision 2) > > [scriptable, builtinclass, uuid(a588b6f2-d2b9-4024-84c7-be3368546b57)] > interface nsIFileURLMutator : nsISupports > { > /* > + * - Marks the inner URI implementation as one that supports nsIFileURL. there should be a comment this has to be used as the very first call on the mutator, otherwise the information will not be applied (the uri will already be created w/ the flag=false) ::: netwerk/protocol/file/nsFileProtocolHandler.cpp:260 (Diff revision 2) > - nsCOMPtr<nsIURIMutator> mutator; > - rv = url->Mutate(getter_AddRefs(mutator)); > - if (NS_FAILED(rv)) { > - return rv; > - } > nsCOMPtr<nsIFileURLMutator> fileMutator = do_QueryInterface(mutator, &rv); I think you can: nsCOMPtr<nsIFileURLMutator> fileMutator = new nsStandardURL::Mutator(); ?
Attachment #8957171 - Flags: review?(honzab.moz) → review+
Pushed by valentin.gosu@gmail.com: https://hg.mozilla.org/integration/autoland/rev/88130a542fb3 Add nsIURIMutator method to mark when the URI implementation should support nsIFileURL r=mayhemer https://hg.mozilla.org/integration/autoland/rev/65b8727bfe76 Make the constructor of nsJARURI private r=mayhemer https://hg.mozilla.org/integration/autoland/rev/9f37df3c62e1 Make the constuctors of URI implementations private r=mayhemer
Flags: needinfo?(valentin.gosu)
Pushed by valentin.gosu@gmail.com: https://hg.mozilla.org/integration/autoland/rev/12eb3cffb3a5 Add nsIURIMutator method to mark when the URI implementation should support nsIFileURL r=mayhemer https://hg.mozilla.org/integration/autoland/rev/60b94194d25c Make the constructor of nsJARURI private r=mayhemer https://hg.mozilla.org/integration/autoland/rev/6e828540dc35 Make the constuctors of URI implementations private r=mayhemer
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: