aboutcode-org / aboutcode-org/saneyaml

Saneyaml doesn't support whitespaces/empty lines

オープン
#9 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
good first issue help wanted
主要言語
Python
スター
10
フォーク
4
PR マージ指標
30日以内にマージされた PR はありません

説明

Reference: https://github.com/nexB/scancode-toolkit/issues/3219

We use pyyaml as YAML dumper with unicode support set to True, and pyyaml also fails to load yaml objects which has text with irregular whitespace in them. An example:

Text at path:
```
Apache License
Version 2.0, January 2004

TERMS AND CONDITIONS
```

We run the following to create a yaml file:

```
license_location = test_env.get_test_loc('yaml/simple-license.txt')
with io.open(license_location, encoding='utf-8') as res:
license_text = res.read()
data = {}
data["license_text"] = license_text
yaml_string = saneyaml.dump(data, indent=4)
yaml_location = test_env.get_test_loc('yaml/simple-license.yaml')
with io.open(yaml_location, 'w') as o:
o.write(yaml_string)
```

Now on this, both `loaded_yaml = saneyaml.load(yaml_string)` and `loaded_yaml = yaml.load(yaml_string)` and `yaml.CSafeLoader(yaml_string).get_data()` fails with the same error as the referenced issue above.

We need to update the dump function in Saneyaml to modify the dumper to check for irregular whitespace and only dump valid yaml.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。