Page MenuHomePhabricator

wfAcceptToPrefs doesn't support spaces in the Accept header string
Closed, ResolvedPublic

Description

Author: mark

Description:
If the Accept header passed to wfAcceptToPrefs() contains spaces the resulting list of mime types will have spaces at the beginning of each type. They should be trimmed.


Version: 1.12.x
Severity: minor

Details

Reference
bz14273

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:13 PM
bzimport set Reference to bz14273.
bzimport added a subscriber: Unknown Object (MLST).

mark wrote:

I was given SVN commit access a while ago, but have never done anything with it. I'm happy to commit this tiny change if folks think it's worth while.

-mark

mark wrote:

adding self to the cc list

mark wrote:

one line patch to add trim()

Attached:

ayg wrote:

Tabs, not spaces. :) Can't comment on the patch itself, I don't know why/whether these need to be trimmed.

mark wrote:

Well, the reason why the extra whitespace would need to be trimmed is that as it is the array output by wfAcceptToPrefs() won't work as the input to wfNegotiateType(), specifically with the Accepts header sent by Konqueror. The array looks something like this (pseudo code):

array(
"text/html" => 1,
" text/plain" => 1,
" image/*" => 1
);

note the extra spaces. If wfNegotiateType() tries to match this with a list of mime types from somewhere else it won't work, because the extra spaces mean that the first part of the mime type doesn't match.