unknwon

unknwon

Wild kid in the junkyard.

Member Since 9 years ago

@sourcegraph, Shanghai, China

Experience Points
1.17w
follower
Lessons Completed
5
follow
Lessons Completed
3
stars
Best Reply Awards
38
repos

2781 contributions in the last year

Pinned
⚡ Gogs is a painless self-hosted Git service
⚡ Universal code search (self-hosted)
⚡ A fantastic modular Go web framework boiled with dependency injection
⚡ Package macaron is a high productive and modular web framework in Go.
⚡ Package ini provides INI file read and write functionality in Go
⚡ 《The Way to Go》中文译本,中文正式名《Go 入门指南》
Activity
Dec
2
4 days ago
Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

Activity icon
published release 1.66.2

unknwon in go-ini/ini create published release 1.66.2

createdAt 3 days ago
Activity icon
created tag

unknwon in go-ini/ini create tag v1.66.2

createdAt 3 days ago
push

unknwon push go-ini/ini

unknwon
unknwon

Fix nested values can span sections (#306)

commit sha: c71eccd557feacd4fcd29f322a99e98870f908b7

push time in 3 days ago
pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

unknwon
unknwon

GitHub Action got stuck and does not run, I'm gonna try close and reopen the PR see if helps.

pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

pull request

unknwon merge to go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first reported here.

Have you added test cases to catch the problem?

The TestPythonMultiline_EOF was added.

Activity icon
published release 1.66.1

unknwon in go-ini/ini create published release 1.66.1

createdAt 3 days ago
Activity icon
created tag

unknwon in go-ini/ini create tag v1.66.1

createdAt 3 days ago
push

unknwon push go-ini/ini

unknwon
unknwon

Fix python multiline EOF error (#309)

commit sha: 3ca1e6ad324e3b4b4cb107e6c5117f4ec475de08

push time in 3 days ago
pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first reported here.

Have you added test cases to catch the problem?

The TestPythonMultiline_EOF was added.

pull request

unknwon merge to go-ini/ini

unknwon
unknwon

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first reported here.

Have you added test cases to catch the problem?

The TestPythonMultiline_EOF was added.

Activity icon
issue

unknwon issue flamego/flamego

unknwon
unknwon

docs: add documentation for middleware

This is the tracking issue for tracking the progress of middleware documentation.

  • template
  • session
  • recaptcha
  • csrf
  • cors
  • binding
  • gzip
  • cache
  • brotli
  • auth
  • i18n
  • captcha
Activity icon
issue

unknwon issue flamego/flamego

unknwon
unknwon

all: testing `go.mod` tidiness in CI

We want to make sure go.mod is up-to-date for every pull request for all middleware, including the core framework.

The actual implementation can be seen in this blog post but we should avoid using bash script and see if it's possible to use the exit code to control the GitHub Action's behavior (i.e. fail on exit 1).

Activity icon
issue

unknwon issue flamego/flamego

unknwon
unknwon

cache: support auto-create table for PostgreSQL and MySQL

Component

Middleware

Middleware

https://github.com/flamego/cache

Is your feature request related to a problem? Please describe

The cache middleware require manual creation of the table for PostgreSQL and MySQL backend.

Describe the solution you'd like

Add an option to the postgres.Config and mysql.Config like the following (field name need to be discussed):

type Config struct{
	// ...
	InitTable bool
}

Which automatically creates the table when not exists.

The SQL to create the table can be derived from the tests.

Describe alternatives you've considered

Live with it.

Additional context

Feel free to ask more details or clarifying questions!

If you would like to contribute on the implementation, please:

  1. Comment on the issue for taking the responsibility so everyone knows.
  2. Acknowledge that the expected timeline is one week.

Code of Conduct

  • I agree to follow this project's Code of Conduct
Activity icon
issue

unknwon issue flamego/flamego

unknwon
unknwon

session: support auto-create table for PostgreSQL and MySQL

Component

Middleware

Middleware

https://github.com/flamego/session

Is your feature request related to a problem? Please describe

The session middleware require manual creation of the table for PostgreSQL and MySQL backend.

Describe the solution you'd like

Add an option to the postgres.Config and mysql.Config like the following (field name need to be discussed):

type Config struct{
	// ...
	InitTable bool
}

Which automatically creates the table when not exists.

The SQL to create the table can be derived from the tests, e.g. https://github.com/flamego/session/blob/22e773287cf151692d5d848e31e994a75edc9d6c/postgres/postgres_test.go#L70-L73

Describe alternatives you've considered

Live with it.

Additional context

Feel free to ask more details or clarifying questions!

If you would like to contribute on the implementation, please:

  1. Comment on the issue for taking the responsibility so everyone knows.
  2. Acknowledge that the expected timeline is one week.

Code of Conduct

  • I agree to follow this project's Code of Conduct
pull request

unknwon merge to sourcegraph/zoekt

unknwon
unknwon

zoekt-sourcegraph-indexserver: set internal actor on requests

Requests from zoekt-sourcegraph-indexserver do not have actor IDs set, which means our actor middleware must treat an unset actor header as an internal user. This change explicitly sets an internal actor on outgoing requests, which removes the need for such a workaround.

Closes https://github.com/sourcegraph/sourcegraph/issues/28447

Activity icon
issue

unknwon issue flamego/flamego

unknwon
unknwon

middleware: set up Dependabot

Use Sourcegraph Batch Changes to set up Dependabot for all middleware, example: https://github.com/flamego/flamego/blob/main/.github/dependabot.yml

pull request

unknwon merge to sourcegraph/sourcegraph

unknwon
unknwon

httpcli, actor: propagate actor on all internal requests

Propagates actor ID on all outgoing internal requests and adds middleware that services can use to pick up actors from incoming requests and add it to the request context. The middleware is currently only applied to frontend's internal API handler, which already has something similar. Also adds metrics to see the number of requests that are user-authenticated vs internal-authenticated.

This more generalized actor handling replaces all existing usage of X-Sourcegraph-User-ID. The header is also renamed to X-Sourcegraph-Actor-ID to more accurately reflect actor.ID, though backcompat is retained mostly with the old behaviour (though drops support for setting the ID to 0 to imply an internal user)

The plan is to also apply this to searcher separately in https://github.com/sourcegraph/sourcegraph/issues/28412 (in the scope of PD 503 #27916)

Closes https://github.com/sourcegraph/sourcegraph/issues/27918

Related changes

Turned out to require a number of changes because of import cycles, now that httpcli imports actor to add actor propagation to the default internal HTTP client

close pull request

unknwon wants to merge sourcegraph/sourcegraph

unknwon
unknwon

httpcli, actor: propagate actor on all internal requests

Propagates actor ID on all outgoing internal requests and adds middleware that services can use to pick up actors from incoming requests and add it to the request context. The middleware is currently only applied to frontend's internal API handler, which already has something similar. Also adds metrics to see the number of requests that are user-authenticated vs internal-authenticated.

This more generalized actor handling replaces all existing usage of X-Sourcegraph-User-ID. The header is also renamed to X-Sourcegraph-Actor-ID to more accurately reflect actor.ID, though backcompat is retained mostly with the old behaviour (though drops support for setting the ID to 0 to imply an internal user)

The plan is to also apply this to searcher separately in https://github.com/sourcegraph/sourcegraph/issues/28412 (in the scope of PD 503 #27916)

Closes https://github.com/sourcegraph/sourcegraph/issues/27918

Related changes

Turned out to require a number of changes because of import cycles, now that httpcli imports actor to add actor propagation to the default internal HTTP client

unknwon
unknwon

Ah good catch! the old middleware does indeed treat the 0 UID/no UID case explicitly as an internal actor

Just speaking on the matter, this is so risky and such a bad practice for security 😂

pull request

unknwon merge to sourcegraph/sourcegraph

unknwon
unknwon

Remove dbtesting package

This removes the deprecated dbtesting package. It was only used in ~40 tests, so I just finished it off by converting them all to use dbtest.NewDB(). For the most part, this was just a mechanical rename, but I've marked any additional work needed to do this or fix tests explicitly with comments. There were a few spots that depended on the global behavior of dbtesting.

pull request

unknwon merge to sourcegraph/sourcegraph

unknwon
unknwon

Preselect radio button for org owners

Preselect the "Sync selected repositories" radio button when managing repositories for an Org Screenshot 2021-12-01 at 16 14 00

Testing

  1. For an org without repositories, navigate to "Manage repositories" view and observe the only visible radio button is preselecteed
  2. For a user without repositories, navigate to "Manage repositories" view and observe the "Sync selected repositories" is not selected
unknwon
unknwon

Changes LGTM. What is the context though? Why we shouldn't pre-select on user's settings page?

Dec
1
5 days ago
Activity icon
issue

unknwon issue comment flamego/flamego

unknwon
unknwon

router: fix slash path trimming

Describe the pull request

Fix the wrong path trimming behavior, which makes route /{**: **} can get the correct parameter value when there is a slash at the end of the path.

Link to the issue: https://github.com/flamego/flamego/issues/75

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code.
Activity icon
published release 1.0.1

unknwon in flamego/flamego create published release 1.0.1

createdAt 4 days ago