h5p / h5p-php-library

GNU General Public License v3.0
124 stars 128 forks source link

New line in "authorComments" in metadata: h5p file can't be imported #96

Open JsBergbau opened 3 years ago

JsBergbau commented 3 years ago

If you enter text in the field "Autor comments" and hit Enter a new line is generated, like here grafik

In the JSON is then

"authorComments":"Test\nTest"

As long as the h5p stays in your LMS no problem, but when you try to import in another sytem it fails grafik

I think the error is in https://github.com/h5p/h5p-php-library/blob/master/h5p.classes.php

'authorComments' => '/^.{1,5000}$/',

When you try it here https://regex101.com/r/IS3lUT/1 it finds no match. When you remove the second line, it matches again.

I've tried in course presentation and Find the words, in both this error occurs.

otacke commented 3 years ago

@JsBergbau I agree, the regular expression doesn't cover this case. Would your mind creating a pull request to fix the issue?

JsBergbau commented 3 years ago

Done https://github.com/h5p/h5p-php-library/pull/97

otacke commented 3 years ago

@JsBergbau Cool! Hope the H5P core team will find time to take care of it soon.