Skip to content

Bug: unescaped special characters in visible project name cause kobweb run to config error #14

@EgorBron

Description

@EgorBron

It's not that critical, but I wanted to report it.


While setting up the project with kobweb create, it allows to pass any kind of character to the visible name of the project:

$ kobweb create app/empty
...
? What is the user-visible display title for your project?
> Foo's "Bar\Baz"
...

However, the config is stored in YAML, and it does not allow unescaped quotes and backslashes, leading to a config error when running the app via kobweb run:

$ kobweb run -p foobar/site
✗ A .kobweb folder's `conf.yaml` file seems to have been deleted at some point. This is not expected and Kobweb cannot run without it. Consider restoring your `conf.yaml` file from source control history if possible, or create a new, temporary Kobweb project from scratch and copy its `conf.yaml` file over, modifying it as necessary.

(BTW, the message confused me the first time, and I thought it was a problem with my Linux distribution, but it's not)


So, what causes such issue?

Currently, the code that checks config validity, is just a null check on config content:

fun assertKobwebConfIn(kobwebFolder: KobwebFolder): KobwebConf {
return KobwebConfFile(kobwebFolder).content
?: throw KobwebException("A .kobweb folder's `conf.yaml` file seems to have been deleted at some point. This is not expected and Kobweb cannot run without it. Consider restoring your `conf.yaml` file from source control history if possible, or create a new, temporary Kobweb project from scratch and copy its `conf.yaml` file over, modifying it as necessary.")
}

Which was always null on any parse error. I did a quick check, and it seems to lead to a non-strict YAML parser (not really sure):

https://github.com/varabyte/kobweb/blob/17e25243da037a2c3373cca33969ea97175974a4/common/kobweb-common/src/main/kotlin/com/varabyte/kobweb/project/conf/KobwebConf.kt#L233-L237

A possible solution would be to automatically escape all special symbols and show the user a small warning so they don't try it next time.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions