-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Allow binary values in parameters. #25928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -511,6 +511,12 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase = | |
} | ||
$arguments[$key] = new TaggedIteratorArgument($arg->getAttribute('tag')); | ||
break; | ||
case 'binary': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It this really legitimate? I mean: if There was a problem hiding this comment. 6293Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked for a way to indicate in a XML file (which should be a valid UTF-8 file) that a value was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO using the same term here is legitimate. I would keep it as is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, sorry, I misread the code, all good here |
||
if (false === $value = base64_decode($arg->nodeValue)) { | ||
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="binary" is not a valid base64 encoded string.', $name)); | ||
} | ||
$arguments[$key] = $value; | ||
break; | ||
case 'string': | ||
$arguments[$key] = $arg->nodeValue; | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can preg_match return
false
here?What's the reasoning for choosing this regexp? (any reference/inspiration maybe?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
$value
is not an UTF-8 character string,preg_match
will returnfalse
because of theu
modifier.Regexp was chosen to detects all characters which are control characters
\p{Cc}
and not a space (which are valid ascii). I mean, putting a bell character in a string is very unlikely done in purpose. I don't know of a way to put this in a file except by copy/paste.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, I see. Then why unicode at all? No need for the
u
modifier, isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I not set
u
modifier, I can NOT use\p{Cc}
to find the allowed characters as its extension for unicode. My first try was just selecting all characters outside standard ASCII but it would filter too much IMO.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for unicode, let's list the ASCII Cc explicitly, here they are:
https://en.wikipedia.org/wiki/Unicode_control_characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want a different regex for XML and PHP serialization? I mean, in XML, I need to check whether string contains only valid UTF-8 characters implying check with the
u
modifier.For PHP, I can only check for
[\0-\x1f\x7f]
but then simple strings like"Foo\tTab"
would be base64 encoded whereas"\xf0"
would not.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest only one way to detect binary, and using this:
[\x00-\x08\x0B\x0E-\x1A\x1C-\x1F\x7F]