Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkupText - Invalid Characters #8

Closed
naveen521kk opened this issue Jan 9, 2021 · 3 comments · Fixed by #9
Closed

MarkupText - Invalid Characters #8

naveen521kk opened this issue Jan 9, 2021 · 3 comments · Fixed by #9
Assignees

Comments

@naveen521kk
Copy link
Member

naveen521kk commented Jan 9, 2021

Just tried this

>>> MarkupText('<<lllll><<>><><>©')
MarkupText('<<lllll><<>><><>©')

I see an empty SVG file created with the following warnings over at console.

(process:4516): Pango-WARNING **: 23:48:47.481: pango_layout_set_markup_with_accel: Error on line 1 char 17: “<lllll” is not a valid name

Suggestion: Use pango_parse_markup and raise an error when markup is invalid. @PhilippImhof are you interested in doing this, or else I will do.

@naveen521kk naveen521kk changed the title MarkupText - Invalid Characters Passes MarkupText - Invalid Characters Jan 9, 2021
@PhilippImhof
Copy link
Member

PhilippImhof commented Jan 9, 2021

Good catch. I didn't think of implementing a sanity check, knowing that Pango would simply fail and the error message was rather clear. I will gladly do it, but won't be able for the next few days.

If you think it cannot wait, I am fine with you fixing it. Remember that the color and gradient part must be parsed and stripped before the check, as they are not supported by Pango. (Just to be sure, but you would probably have thought of that anyway.)

@naveen521kk
Copy link
Member Author

No hurry for me, just do it when you are free :)

knowing that Pango would simply fail and the error message was rather clear.

If Pango had tried to exit, it would have made Python Crash, at least it just warns or else things would be difficult.

@PhilippImhof
Copy link
Member

If Pango had tried to exit, it would have made Python Crash, at least it just warns or else things would be difficult.

I know. I tested that beforehand. 👍

naveen521kk added a commit that referenced this issue Jan 11, 2021
* Add validation for Pango Markup

* Changes after code review

* Test for markup validation

* Better error messages if tests fail

* Lint

* Dummy commit to trigger check

* Removing dummy comment

* Lint fix and remove unecessary cdef extern block

* remove unnecessary guint32 definition

Co-authored-by: Syrus Dark <naveen@syrusdark.website>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants