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

Fix get_language_name for unknown languages #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

md-5
Copy link

@md-5 md-5 commented Jan 6, 2019

If the language is not known, then language_data will not be initialized properly. We should therefore use the user's language input instead.

If the language is not known, then language_data will not be initialized properly. We should therefore use the user's language input instead.
@jgehrcke
Copy link

@cweiske do you consider the patches from @md-5? Thanks!

@@ -611,7 +611,7 @@ public function error() {
*/
public function get_language_name() {
if (GESHI_ERROR_NO_SUCH_LANG == $this->error) {
return $this->language_data['LANG_NAME'] . ' (Unknown Language)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have this set even in case of errors so there's no need for every location to do some special check for such situations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this comment. Are you suggesting to set $this->language_data['LANG_NAME'] in set_language() when the language can't be found?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Having one line access $this->language, while everything else accesses $this->language_data['LANGUAGE_NAME'] seems rather inconsistent. And as most of the parser assumes there's some (somewhat) consistent structure in $this->langauge_data anyway we just might opt to have set_language do that setup instead if some error happens.

splitbrain added a commit to splitbrain-forks/geshi-1.0 that referenced this pull request Apr 29, 2020
As suggested in GeSHi#123 this always initialized the language name, even if
the language file cannot be found later.
splitbrain added a commit to splitbrain-forks/geshi-1.0 that referenced this pull request Apr 29, 2020
As suggested in GeSHi#123 this always initializes the language name, even if
the language file cannot be found later.
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 this pull request may close these issues.

4 participants