Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpFoundation] automatically generate safe fallback filename#16656

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.3fromxabbuh:issue-16603
Mar 4, 2016

Conversation

@xabbuh
Copy link
Member

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#16603
LicenseMIT
Doc PR

@Yannik
Copy link

Hi Christian,
thanks a lot for addressing this!
Maybe it's possible to convert the default filename to the nearest ascii equivalent instead of just replacing it with an underscore.
For example: 'föö.html' => 'foo.html' instead of 'f__.html',
'fòôbàř.txt' => 'foobar.txt' instead of 'f_____.txt'.
I am not confident in what's the best way to do this - I usehttps://github.com/danielstjules/Stringy#toascii for such purposes in my own applications.

Best regards, Yannik

@nicolas-grekas
Copy link
Member

Why couldn't we useRFC 2231?
See also this old "paper" on the topic:http://greenbytes.de/tech/tc2231/
Doing transliterations works for western languages but is quite limited in the general case, I'm not really fan of this approach...

@xabbuh
Copy link
MemberAuthor

@nicolas-grekas Encoding a string according to RFC 2231 leads to% characters in the resulting string, doesn't it? This would conflict with how themakeDisposition() method of theResponseHeaderBag is working (seehttps://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php#L256) (but maybe we need to fix it there). What do you think?

@ghost
Copy link

@xabbuh Your PR is awesome! Hopefully this will be merged into Symfony.

@fabpot
Copy link
Member

@nicolas-grekas@xabbuh Can we find something that works for everyone here? I'd like to merge this one ASAP if possible.

@xabbuh
Copy link
MemberAuthor

If we removed the limitation of not being able to have the percent character in the fallback filename, we could use RFC 2231 afaics as@nicolas-grekas proposed. But I am not sure why this check was added initially.

}

if ('' ===$filenameFallback && (!preg_match('/^[\x20-\x7e]*$/',$filename) ||false !==strpos($filename,'%'))) {
$encoding =mb_detect_encoding($filename);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

mb_detect_encoding($string, null, true) to enable strict mode (non-strict is useless)

@fabpot
Copy link
Member

@xabbuh Do you have time to finish this one? If not, just let me know and I will finish it for you.

@xabbuh
Copy link
MemberAuthor

@fabpot@nicolas-grekas I pushed an update.

@fabpot
Copy link
Member

👍

1 similar comment
@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commit03721e3 intosymfony:2.3Mar 4, 2016
fabpot added a commit that referenced this pull requestMar 4, 2016
…name (xabbuh)This PR was merged into the 2.3 branch.Discussion----------[HttpFoundation] automatically generate safe fallback filename| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#16603| License       | MIT| Doc PR        |Commits-------03721e3 automatically generate safe fallback filename
@xabbuhxabbuh deleted the issue-16603 branchMarch 4, 2016 09:44
@Yannik
Copy link

@fabpot Will this be merged into the more current releases of symfony?

@xabbuh
Copy link
MemberAuthor

@Yannik Yes, we regularly merge lower branches into all higher maintained branches.

This was referencedMar 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@xabbuh@Yannik@nicolas-grekas@fabpot@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp