Ignore UTF8 BOMs from funny windows clients.#42
Ignore UTF8 BOMs from funny windows clients.#42clavoie-acquisio wants to merge 1 commit intomasterfrom unknown repository
Conversation
|
Cool! Can you add a test please. |
|
With pleasure. I'm just wondering how you'd like that done -- adding random Happy to do it... how? On Fri, May 27, 2016 at 3:56 PM, Tobias Schmidt notifications@github.com
|
|
Would it be enough to create a byte array with the bom bytes at the On Fri, May 27, 2016 at 3:59 PM, clavoie-acquisio notifications@github.com
|
|
Given prometheus/prometheus#1679 (comment), should we allow BOMs? I don't care either way, but it seems the recommendation is not to. |
|
My first reaction was to follow the robustness principle and be forgiving on the input, I do agree with that recommendation though. BOM has always been an ugly wart, I'm surprised it still exists. Or maybe not ... @clavoie-acquisio What client is that which sends the BOM? What client library is being used which sets that? What prevents you from not removing the BOM header instead? |
|
Given https://tools.ietf.org/html/rfc3629 , I'm inclined to not allow BOMs, but explicitly add to the format specification that BOMs are not allowed. However, if this is something that is a pain to get rid of on the side of the generator, we might go for being "forgiving on the input". BTW: The test only fail on Go 1.4 which doesn't compile our dependencies anymore. We should remove it from the test. |
|
Yeah, I'm fond of allowing BOMs for two big reasons:
I could also make this configurable on a per-target basis, and not On Sat, May 28, 2016 at 8:13 AM, Björn Rabenstein notifications@github.com
|
|
Your reference to the modern world is exactly the reason why we have the feeling it should not be supported. A byte order is completely meaningless in UTF-8 encoding and one should expect that current software should not need such a wart anymore to handle UTF-8 correctly. As the recommendation is to not set it, I think we should have good arguments why it's necessary to support it anyways. Do you save the textfiles with your editor? Can you just disable the BOM header in your editor? If some client library writes out the BOM header, would it be possible to change that? |
|
On Sat, May 28, 2016 at 5:31 PM, Tobias Schmidt notifications@github.com
Christian Lavoie |
|
Given that the text format is our most lenient fallback (e.g. if no content-type header is present), where we just try to parse anything as text format, I tend to allow BOMs, but treat them by ignoring. We should also add that to the spec, as in "BOMs are tolerated but completely ignored, i.e. the content is always considered UTF-8, no matter what the BOMs say." And BTW: #43 will fix the test. |
|
Sounds like it's not easy to get rid of BOM headers in Windows environments, so I agree that we should handle it. Please add a test which verifies the correct handling. The format specification @beorn7 suggested needs to be added in the prometheus/doc repository. |
| maybeBOM, err := p.buf.Peek(3) | ||
| if len(maybeBOM) == 3 && maybeBOM[0] == 0xEF && maybeBOM[1] == 0xBB && maybeBOM[2] == 0xBF && err == nil { | ||
| // The common case dealing with funny Windows clients | ||
| log.Debug("Discarding BOM") |
There was a problem hiding this comment.
We don't use any logging anywhere in this package. It might come as a surprise to the (possibly very diverse) users, and it's pulling in another dependency. I think it's fine to silently swallow the BOMs.
There was a problem hiding this comment.
Will do.
On Tue, May 31, 2016 at 6:32 AM, Björn Rabenstein notifications@github.com
wrote:
In expfmt/text_parse.go
#42 (comment):@@ -125,6 +126,15 @@ func (p *TextParser) reset(in io.Reader) {
} else {
p.buf.Reset(in)
}
+
- // Some clients like to throw in UTF-8 BOM chars
- maybeBOM, err := p.buf.Peek(3)
- if len(maybeBOM) == 3 && maybeBOM[0] == 0xEF && maybeBOM[1] == 0xBB && maybeBOM[2] == 0xBF && err == nil {
// The common case dealing with funny Windows clientslog.Debug("Discarding BOM")We don't use any logging anywhere in this package. It might come as a
surprise to the (possibly very diverse) users, and it's pulling in another
dependency. I think it's fine to silently swallow the BOMs.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/prometheus/common/pull/42/files/1e1e0c1c905808faedb252d7fbb96f35a43726f7#r65157940,
or mute the thread
https://github.com/notifications/unsubscribe/AStJnk1lrBxaqHlLQzUtcFti7h2pqeAYks5qHA5AgaJpZM4Iozt3
.
|
Since there don't seem to be further objections, let's go with what @grobie said: |
|
@clavoie-acquisio Are you still on this? |
|
Yup, got distracted with deployment of prometheus. Should be able to update
|
|
ping @clavoie-acquisio :) |
|
Another ping @clavoie-acquisio |
|
@clavoie-acquisio @fabxc @juliusv I'm happy to pick this up and add some tests if there's still interest. |
|
Please go for it Jud!
…On Sun, Feb 19, 2017, 00:52 Jud White ***@***.***> wrote:
@clavoie-acquisio <https://github.com/clavoie-acquisio> @fabxc
<https://github.com/fabxc> @juliusv <https://github.com/juliusv> I'm
happy to pick this up and add some tests if there's still interest.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#42 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAANaGNvk-t0nJHKfQawkOd6_OGV0FCrks5rd8qrgaJpZM4Iozt3>
.
|
|
Potentially relevant: https://github.com/dimchansky/utfbom |
b990f48 Merge pull request prometheus#42 from kinvolk/lorenzo/fix-git-diff 224a145 Check if SHA1 exists before calling `git diff` 1c3000d Add auto_apply config for wcloud 0ebf5c0 Fix wcloud -serivice 4fe078a Merge pull request prometheus#39 from weaveworks/fix-wrong-subtree-use 3f4934d Remove generate_latest_map 48beb60 Sync changes done directly in scope/tools 45dcdd5 Merge pull request prometheus#37 from weaveworks/fix-mflag-missing b895344 Use mflag package from weaveworks fork until we find a better solution e030008 Merge pull request prometheus#36 from weaveworks/wcloud-service-flags 9cbab40 Add wcloud Makefile ef55901 Review feedback, and build wcloud in circle. 3fe92f5 Add wcloud deploy --service flag 3527b56 Merge pull request prometheus#34 from weaveworks/repo-branch 92cd0b8 [wcloud] Add support for repo_branch option 9f760ab Allow wcloud users to override username 38037f8 Merge pull request prometheus#33 from weaveworks/wcloud-templates 7acfbd7 Propagate the local username e6876d1 Add template fields to wcloud config. f1bb537 Merge pull request prometheus#30 from weaveworks/mike/shell-lint/dont-error-if-empty e60f5df Merge pull request prometheus#31 from weaveworks/mike/fix-shell-lint-errors e8e2b69 integrations: Fix a shellcheck linter error a781575 shell-lint: Don't fail if no shell scripts found db5efc0 Merge pull request prometheus#28 from weaveworks/mike/add-image-tag 5312c40 Import image-tag script into build tools so it can be shared 7e850f8 Fix logs path dda9785 Update deploy api f2f4e5b Fix the wcloud client 3925eb6 Merge pull request prometheus#27 from weaveworks/wcloud-events 77355b9 Lint d9a1c6c Add wcloud events, update flags and error nicely when there is no config git-subtree-dir: tools git-subtree-split: b990f488bdc7909b62d9245bc4b4caf58f5ae7ea
Once the call succeeds (or maxBackoff reached), errors were no longer logged. From then on, the only log messages generated were first successes after errors.
|
The current decision is that we won't be allowing this, as OpenMetrics forbids it. |
This change is