-
Notifications
You must be signed in to change notification settings - Fork 100
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
base: master
Are you sure you want to change the base?
Conversation
If the language is not known, then language_data will not be initialized properly. We should therefore use the user's language input instead.
@@ -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)'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
As suggested in GeSHi#123 this always initialized the language name, even if the language file cannot be found later.
As suggested in GeSHi#123 this always initializes the language name, even if the language file cannot be found later.
If the language is not known, then language_data will not be initialized properly. We should therefore use the user's language input instead.