Skip to content

Instantly share code, notes, and snippets.

@hakanai
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakanai/9562691 to your computer and use it in GitHub Desktop.
Save hakanai/9562691 to your computer and use it in GitHub Desktop.
User fills in a form like this:
Enter the data you want to process:
+-------------------------------------------------------------------------------------------+
| Content-Type: image/png; |
| name*0*=ISO-2022-JP''%1B%24B%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26; |
| name*1*=%24%28%24*%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26%24%28; |
| name*2*=%24*%1B%28B.png |
+-------------------------------------------------------------------------------------------+
What do you want to do:
[ Parse MIME headers ]
[ Submit ]
The output we want is something like this:
Content-Type: image/png;
name*0*=ISO-2022-JP''%1B%24B%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26;
name*1*=%24%28%24*%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26%24%28;
name*2*=%24*%1B%28B.png
||
|| Parse header parts
\/
Name: Content-Type
Value: image/png
Parameters:
name*0*: ISO-2022-JP''%1B%24B%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26
name*1*: %24%28%24*%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26%24%28
name*2*: %24*%1B%28B.png
||
|| Recombine RFC 2231 parameters:
\/
Name: Content-Type
Value: image/png
Parameters:
name: ISO-2022-JP''%1B%24B%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26%24%28%24*%24%22%24%24%24%26%24%28%24*%1B%28B.png
||
|| Interpret RFC 2231 string:
\/
Name: Content-Type
Value: image/png
Parameters:
name:
encoding: ISO-2022-JP
language: (empty)
content: [ESC-]$B $"$$$&$($*$"$$$&$($*$"$$$&$($*$"$$$&$($* [ESC](B.png
||
|| Decode RFC 2231 string:
\/
Name: Content-Type
Value: image/png
Parameters:
name:
encoding: ISO-2022-JP
language: (empty)
content: [ESC-]$B $"$$$&$($*$"$$$&$($*$"$$$&$($*$"$$$&$($* [ESC](B.png
value: あいうえおあいうえおあいうえおあいうえお.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment