Skip to content

Instantly share code, notes, and snippets.

@brzuchal
Created January 23, 2017 22:32
Show Gist options
  • Select an option

  • Save brzuchal/d7dec81626b1daa17251b4d13676297c to your computer and use it in GitHub Desktop.

Select an option

Save brzuchal/d7dec81626b1daa17251b4d13676297c to your computer and use it in GitHub Desktop.

Table of Contents

PHP RFC: Ommit double-slash in user Stream Wrapper URI

  * Version: 1.0
  * Date: 2017-01-23
  * Author: Michał Brzuchalski <[email protected]>
  * Status: Draft
  * First Published at: http://wiki.php.net/rfc/ommit-double-slash-in-user-stream-wrapper-uri

Introduction

Regarding RFC 2396 defining URI Generic Syntax which specifies URI Syntactic Components:

> The URI syntax is dependent upon the scheme.

> The URI syntax does not require that the scheme-specific-part have > any general structure or set of semantics which is common among all > URI.

Proposal

This RFC proposes to add new flag STREAM_IR_URI to use with stream_wrapper_register in a third parameter.

Passing new flag allows user defined Stream Wrapper class based on streamWrapper prototype to handle URI in their general syntax consisting of <scheme></scheme> and <scheme-specific-part></scheme-specific-part> whose interpretation depends on the scheme.

> <scheme></scheme>:<scheme-specific-part></scheme-specific-part>

Examples

stream_wrapper_register(&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;39&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;test&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;39&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;, MyStreamWrapper&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;58&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;58&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;class, STREAM_IS_URI)&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;59&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59; file_exists(&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;39&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;test&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;58&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;file.txt&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;39&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;)&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;59&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;

Output:

> Stating file: test:file.txt

Backward Incompatible Changes

No backward incompatible changes, when additional flag is missing all handled paths are checked in case of double slash existance after colon (<scheme></scheme>://).

Proposed PHP Version(s)

next PHP 7.x

RFC Impact

To SAPIs

No impact.

To Existing Extensions

No.

To Opcache

No.

New Constants

STREAM_IS_URI = 2 - allows user Stream Wrapper to handle all wariety of URI's without double-slash after colon

Proposed Voting Choices

This project requires a 2/3 majority. The vote is a straight Yes/No vote for accepting the RFC and merging the patch.

Patches and Tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment